1.

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 That Variable?

Answer»

Use KEEP option on a dataset to only select few variables from 100 variables. We can use KEEP option either on set statement or data step statement. If we use on SET statement then only the five variables are created on PDV and only these variables are sent to the OUTPUT dataset. If we use KEEP option on data step statement then all the variables are copied into pdv and after any manipulation only the selected variables on data step statement are PROCESSED and sent to output dataset.

data abc;

set xyz (keep= ab cd ef GH);

run;

data abc(keep= ab cd ef gh IJ);

set xyz;

 ij=ab+jk;

run;

Use KEEP option on a dataset to only select few variables from 100 variables. We can use KEEP option either on set statement or data step statement. If we use on SET statement then only the five variables are created on pdv and only these variables are sent to the output dataset. If we use KEEP option on data step statement then all the variables are copied into pdv and after any manipulation only the selected variables on data step statement are processed and sent to output dataset.

data abc;

set xyz (keep= ab cd ef gh);

run;

data abc(keep= ab cd ef gh ij);

set xyz;

 ij=ab+jk;

run;



Discussion

No Comment Found