Interview Questions   Tutorials   Discussions   Programs   Videos   

SAS - 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?




394
views
asked mar September 20, 2014 06:29 AM  

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?


           

1 Answers



 
answered By vishnoiprem   0  

Use KEEP= dataset option (data statement or set statement) or KEEP

statement in a datastep.
 eg.

    Data fewdata (keep = var10 var11);
      Set fulldata (Keep= VAR1 VAR2 VAR3 VAR4 VAR5);
      Keep var6 var7;
   Run;

Code a PROC SORT on a data set containing State, District and County as the primary variables, along with several numeric variables.

Proc sort data= Dist_County;

By state district city;
Run;

use select statement with just those 5 variables:

proc sql;
create table only5 as
select var1,var2,var3,var4,var5
from example;
quit; 
flag   
   add comment

Your answer

Join with account you already have

FF

Preview


Ready to start your tutorial with us? That's great! Send us an email and we will get back to you as soon as possible!

Alert