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



If you have a data set that contains 100 variables, but you need only five of those, what is the co..

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

If you have a data set that contains 100 variables, but you need only five of those, what is the co..

Answer / john sikha

Use keep followed by variables you required

Is This Answer Correct ?    23 Yes 2 No

If you have a data set that contains 100 variables, but you need only five of those, what is the co..

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

If you have a data set that contains 100 variables, but you need only five of those, what is the co..

Answer / ganesh

We can either use keep or drop option for selecting those
five variables.

Is This Answer Correct ?    11 Yes 2 No

If you have a data set that contains 100 variables, but you need only five of those, what is the co..

Answer / ravira

data set name ;
set old data set name ( keep = a b c d e);
run;

By using above concept u can read what r the variables u
want to read ,first create data set having many variables ,
then try to read from some variables

Is This Answer Correct ?    9 Yes 0 No

If you have a data set that contains 100 variables, but you need only five of those, what is the co..

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

If you have a data set that contains 100 variables, but you need only five of those, what is the co..

Answer / chandra

data set options keep is best and using proc sql is also.

Is This Answer Correct ?    6 Yes 0 No

If you have a data set that contains 100 variables, but you need only five of those, what is the co..

Answer / gaurav verma

data xyz first obs=first
obs=last;
set zyx;
run;

Is This Answer Correct ?    0 Yes 0 No

If you have a data set that contains 100 variables, but you need only five of those, what is the co..

Answer / santhi

we can use drop command for a limit

Is This Answer Correct ?    1 Yes 11 No

If you have a data set that contains 100 variables, but you need only five of those, what is the co..

Answer / guest

obs = 5

Is This Answer Correct ?    1 Yes 35 No

Post New Answer

More SAS Interview Questions

what are the benefits of data integration? : Sas-di

0 Answers  


How do handle working under pressure?

1 Answers   Oracle, Wipro,


How would you code a merge that will write the matches of both to one data set, the non-matches from the left-most data set to a second data set, and the non-matches of the right-most data set to a third data set.

10 Answers   Accenture,


What would be the value of month at the end of data step execution and how many observations would be there?

0 Answers  


Do you need to know if there are any missing values?

0 Answers  


How to convert .xls file into CSV format?

6 Answers   Quintiles,


How would you generate 1000 observations from a normal distribution with a mean of 50 and standard deviation of 20. How would you use PROC CHART to look at the distribution? Describe the shape of the distribution.

1 Answers  


Describe 5 ways to do a “table lookup” in SAS?

0 Answers  


which date functions advances a date time or date/time value by a given interval? : Sas programming

0 Answers  


Give some ways by which you can define the variables to produce the summary report (using proc report)?

0 Answers  


What does P-value signify about the statistical data?

0 Answers  


In PROC PRINT, can you print only variables that begin with the letter “A”?

8 Answers  


Categories