If you have a data set that contains 100 variables, but you
need only five of those, what is the code to force SAS to
use only those variable?
Answers were Sorted based on User's Feedback
Answer / imran syed
KEEP statement is the most effective form of code.
keep var-1 var-2 var-3 var-4 var-5;
| Is This Answer Correct ? | 24 Yes | 0 No |
Answer / john sikha
Use keep followed by variables you required
| Is This Answer Correct ? | 23 Yes | 2 No |
Answer / aravind9882
u can use keep dataset option or keep statement to limit
the no of variables depending on ur requirement. if u want
process only those 5 variables, u can use keep dataset
option. if u want to limit d variables after d data is
processed u can use keep statement.
data new;
set old(keep=v1 v2 v3 v4 v5);
run;
or
data new;
set old;
keep v1 v2 v3 v4 v5;
run;
| Is This Answer Correct ? | 10 Yes | 0 No |
Answer / ganesh
We can either use keep or drop option for selecting those
five variables.
| Is This Answer Correct ? | 11 Yes | 2 No |
Answer / vinod swarna
use select statement with just those 5 variables:
proc sql;
create table only5 as
select var1,var2,var3,var4,var5
from example;
quit;
| Is This Answer Correct ? | 8 Yes | 0 No |
Answer / chandra
data set options keep is best and using proc sql is also.
| Is This Answer Correct ? | 6 Yes | 0 No |
data xyz first obs=first
obs=last;
set zyx;
run;
| Is This Answer Correct ? | 0 Yes | 0 No |
What is _n_?
How do I CREATE an external dataset with sas code? I would like to create within a sascode a non-exsistent textfile on the host. So I am not forced to create the file befor filling it.
Explain the purpose of substr functions in sas programming.
I have a SCD Type 2 Dimention for Location In which A Sales Office in Having two Surrogate Keys just because of the change in it's Sales Group. SKey SalesGroup Sales Office BeginDate EndDate 280 SG1 SO1 01APR2000 01APR2010 281 SG2 SO1 02APR2010 31MAR2999 Now while loading the Fact, the Lookup ir returning SKey 280 for records before and after 01APR2010. I am not able to give WHERE condition in the Lookup Properties (TranDate between BeginDate and EndDate). Please help.
what is SAS/Graph?
What are exact SAS Base contents..?N what r SAS Tools..?
Which of the following is not created during compilation phase?
How would you code a macro statement to produce information on the SAS log? This statement can be coded anywhere.
Define run-group processing?
if x=round(26.3,10)-1 then x= how much and how explain?
What are the functions used for character handling?
what is hash files in sas and why we are using this one in sas?