How do you read in the variables that you need?

Answers were Sorted based on User's Feedback



How do you read in the variables that you need?..

Answer / neeraja

using keep(for selected variables).keep is a dataset
option.the statment keep is used to specify the number of
variables to be remained within a sas dataset or output.
syntax:keep <var list>
data emp;
keep name no;
input name$ no sal job$;
cards;
......
....

Is This Answer Correct ?    24 Yes 2 No

How do you read in the variables that you need?..

Answer / sheetal

data new (keep = name age sex);
set old;
run;

Is This Answer Correct ?    11 Yes 2 No

How do you read in the variables that you need?..

Answer / murray

I believe it is more efficient to use the KEEP statement on
the input data set, as only required variables are read into
the PDV. This is also true for the WHERE statement.

For small data sets the difference is of course negligible,
however it is always good to practice efficient programming.

Is This Answer Correct ?    9 Yes 0 No

How do you read in the variables that you need?..

Answer / kumaraswamy maduri

Use KEEP or DROP depending on the number of varibales you
require.

Keep: Out of 50 if you require to keep 20 variables it
better to use keep.
Drop: It meaning less to use KEEP when you want to use 35-
40 variables. Its better to drop the remaining variables.
Both mean same but efficient coding is always preffered.

Is This Answer Correct ?    7 Yes 0 No

How do you read in the variables that you need?..

Answer / chiranjeevi

using variable control options.
keep:It decides the no. of variable should remain within the
dataset.

syntax:keep<variablelist>;
example:
data code;
input name$ no sal;
keep name sal;
datalines;
a 32 3000
b 56 7000
c 12 7890
run;
proc print data=code;
run;

Is This Answer Correct ?    5 Yes 1 No

How do you read in the variables that you need?..

Answer / purushotham

I think KEEP option would be the better way to read the
variables that we need. But it's again depends upon how
many number of variables that you want to read from the
input dataset.

Let's say there are 30 variables in data set and you want
to read all the variables except 5 variables from the input
dataset. Then it's efficient to use DROP option to drop
those 5 variables instead of mentioning all 25 variables at
KEEP option.

Is This Answer Correct ?    1 Yes 0 No

How do you read in the variables that you need?..

Answer / aj

Using input statement with column/line pointers,informats and length specifiers.

Is This Answer Correct ?    0 Yes 0 No

How do you read in the variables that you need?..

Answer / hitesh

You can read in the variable with INPUT statement.
There are more than 1 ways use input statement.

eg:
input name$ no sal;

...OR you can read selected fields from byte positions at which they appear in the input file.

eg:
INPUT @1 NAME $20.
@21 No 3.
@24 Sal 7.;

Is This Answer Correct ?    0 Yes 1 No

How do you read in the variables that you need?..

Answer / siri

by using 'scan' statement.
scan <variable name>;

Is This Answer Correct ?    2 Yes 7 No

Post New Answer

More SAS Interview Questions

How long can a macro variable be? A token? : sas-macro

0 Answers  


How would you include common or reuse to be processed along with your statements?

0 Answers  


In sas, what are the areas that you are most interested in? : sas-grid-administration

0 Answers  


What is difference between rename and lable in sas?

10 Answers   Satyam,


What does PROC print, and PROC contents do?

0 Answers  






what are methods to identify duplicate observations?

5 Answers   HCL,


How would you code the criteria to restrict the output to be produced?

9 Answers  


Can we use where and having clauses in a single SAS program. ex: proc sql;     select a,b,c from test      where state in 'KA'      and having <some condition>. Is the above program run correctly, if not why ?     

4 Answers   UHG,


In the SAS Data step what is the difference between the subsetting done by Where and subsetting done by If?

6 Answers   Cognizant,


What is the difference between %put and symbolgen? : sas-macro

0 Answers  


In ARRAY processing, what does the DIM function do?

0 Answers  


What are the difference between ceil and floor functions in sas?

0 Answers  


Categories