Professional Documents
Culture Documents
12. If you do not want any SAS output from a data step, how
would you code the data statement to prevent SAS from
producing a set?
14. Have you ever-linked SAS code? If so, describe the like
and any required statement used to either process the
code or the step itself.
Ans: Scan
17. 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 variables?
Ans:
PROC SORT data-set-name;
BY state district country;
Run;
2) Proc sql;
Create sas-data-set as select * from
old_sas_data_set where var=distinct(var);
quit;
3)Data clean;
Set temp;
By group;
If first.group and last.group then
Run;
20. How would you code a merge that will keep only the
observation that have matches form both sets?
DATA NEW;
MERGE ONE_TEMP (IN=ONE) TWO_TEMP (IN=TWO);
BY NAME;
IF ONE=1 AND TWO=1;
RUN;
21. What is the Program Data Vector (PDV)? What are their
functions?
Ans:
Program Data Vector is the temporary holding area.
For example The WHERE statement is may be more
efficient then the sub setting If (especially if you are
taking a very small sunset from a large file) because it
checks on the validity of the condition to see if the
observation is to be kept or not. This temporary holding
area is called the program data vector (PDV).
A) Input Buffer
B) Program Data Vector(pdv)
C) Descriptor information
BASE SAS:
30. What is the effect of the OPTION statement ERROR=1?
NOTE:
You cannot use the POINT= option with any of the
following:
BY statement
WHERE statement
WHERE= data set option
transport format data sets
sequential data sets (on tape or disk)
a table from another vendor's relational database
management system.
Ans:
Ans: For vary large data set with many variables we can
make use of arrays in the SAS systerm.
41. How would you create a data set with 1 observation and 30
variables from a data set with 30 observations and 1
Variable?
Ans: Using Proc Transpose and also do with the sas arrays.
44. What are _numeric_ and _character_ and what do they do?
Ans: If we want to do a particular task for all the
numeric variable we can use the _numeric_ and same as
if we want to do a particular task for all the
character variable we can use the _character_
Ans: INPUT data set option, SAS statement option and then
OUTPUT option.
Missing Value:
56. How many missing values are available? When might you use
them?
FUNCTIONS:
Ans:
data _null_; X=1/3;
if X=.333 then ;
put fraction;
run;
SCORE=(item1 +item2+item3+..+item50)/50;
You would be in big trouble if any of the items had
missing values. When SAS statement tries to do
arithmetic operation on missing values, the result is
always missing.
PROCs:
69. If you were given several SAS data sets you were
unfamiliar with, how would you find out the variable names
and formats of each dataset?
70. How would you keep SAS from overlaying the SAS set with
its sorted version?
71. In PROC PRINT, can you print only variable that begin with
the letter A
Ans: Yes we can print variable which begin with the letter
A by using the WHERE statement in the PROC PRINT
statement
72. What are some differences between PROC SUMMARY and PROC
MEANS?
Ans:
1) PROC MEANS produces subgroup statistics only when a
BY statement is used and the input data has been
previously sorted (use PROC SORT) by the BY
variables.PROC SUMMARY automatically produces
statistics for all subgroups, giving you all the
information in one run that you would get by
repeatedly sorting a data set by the variables that
define each subgroup and running PROC MEANS/.
PROC FREQ:
Ans
The statement for single-level.
DATA MAR.FREQTEST;
SET BAS.AMPERS;
PROC FREQ DATA =MAR.FREQTEST;
TABLE AGE;
RUN;
Ans:
The statement for multilevel.
DATA MAR.FREQTEST;
SET BAS.AMPERS;
PROC FREQ DATA =MAR.FREQTEST;
TABLE AGE * gender;
RUN;
78. Code the option that will allow MEANS to include missing
numeric data to be included in the report.
MERGING/UPDATING :
Ans:If you want to merge two data set that have different
variable and only one variable as a common variable
with that unique variable we can merge the data set
with one-on-one merge.
83. What is the problem with merging two data set that have
variable with the same name but different data?
84. When would you choose to MERGE two data sets together and
when would you SET two data sets?
85. Which data set is the controlling data set in the MERGE
statement?
87. Explain the message MERGE HAS ONE OR MORE DATASETS WITH
REPEATS OF BY VARIABLE.
Ans:
Use the keyword _NULL_, which allows the power of the
DATA step without creating a data set.
89. What is the pound sign used for the DATA _NULL_?
MACRO:
91. What system option would you use to help debug a macro?
Ans: %mend
98. If you use a SYMPUT in a DATA step, when and where can you
use the macro variable?