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 |
hi tell be about pfizer? how to compare the work with other companies ? please tell me how to login and work also?
What are the difference between sas functions and procedures?
data voter; input Age Party : $1. (Ques1-Ques4)($1. + 1); datalines; 23 D 1 1 2 2 45 R 5 5 4 1 67 D 2 4 3 3 39 R 4 4 4 4 19 D 2 1 2 1 75 D 3 3 2 3 57 R 4 3 4 4 ; Idont understand what the (Ques1-Ques4)($1. + 1) means. I have seen (Ques1-Ques4)(4*$1.), but what is (Ques1-Ques4)($1. + 1)? Appreciate all help Thanks
Write a SAS macro to calculate number of numbers in an email address
how to get second highest salary from a employee table and how get a 5th highest salary from a employee table?
what is the difference between compiler and interpreter? give any one example (software product) that act as a interpreter?
36 Answers Accenture, College School Exams Tests, CTS, IBM, IHRD, Infosys, Sylhet Engineering College, TCS, Wipro,
What is by-group processing?
What do the mod and int function do? : Sas programming
How can you create a macro variable with in data step? : sas-macro
What is the maximum length of the macro variable? : sas-macro
Mention common programming errors committed in sas ?
Describe a time when you were really stuck on a problem and how you solved it?