FAQfor SAS Interview
FAQfor SAS Interview
A) Date format
B) Character Format
C) Numeric Format
data values left to be read from that line. The @@, therefore,
hold the input record even across multiple iteration of the
data step.
9. Under what circumstances would you code a SELECT construct
instead of IF statement?
Ans: Especially if you are recoding a variable into a
large number of categories.
10. What statement do you code to tell SAS that it is to
write to an external file?
Ans: Filename fileref path;
File fileref;
Put _all_
/* will write all the variables. */
Or put the variables which you require.
11. If reading an external file to produce an external
file, what shortcut to write record without coding
every single variable on the record?
Ans: Put _all _
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?
Ans: By using DATA _NULL_ the desired output is a file
and not a SAS dataset.
13. What is the one statement to set the criteria of a data
that can be coded in any step?
Ans: Options statement
14.
16.
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: Use keep = option;
18.
20. How would you code a merge that will keep only the
observation that have matches form both sets?
Ans: By using the IN internal variable in the merge
statement.
DATA NEW;
MERGE ONE_TEMP (IN=ONE) TWO_TEMP (IN=TWO);
BY NAME;
IF ONE=1 AND TWO=1;
RUN;
their
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).
22. Does SAS Translate (compile) or does it Interpret?
Explain.
Ans: When you submit a DATA step for execution, SAS
checks the syntax of the SAS statements and compiles
them, that is, automatically translates the
statements into machine code. In this phase, SAS
identifies the type and length of each new variable,
and determines whether a type conversion is
necessary for each subsequent reference to a
variable.
Only?
Ans: Drop Keep e.t.c
BASE SAS:
30. What is the effect of the OPTION statement ERROR=1?
Ans: If the particular data step has one or more errors
then end the processing
32. What do the SAS log messages numeric values have been
converted to character mean?
Ans:
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.
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?
Missing Value:
56. How many missing values are available? When might you use
them?
Ans: Two missing values are available in SAS, they are
numeric and character.
57. How do you test for missing values?
Ans: We can test the missing values by using NMISS
option in the input statement
58. How are numeric and character missing values represented
internally?
Ans: The numeric missing values represented as dots(.) and
the character missing values represented as blank
FUNCTIONS:
59. What is the significance of the OF in X=SUM (OF a1-a4,
a6, a9);?
60. What do the PUT and INPUT function do?
Ans: The PUT function is used to identify the logic
Problem Which piece of code is executed and not
executed what the current value of the particular
variable and what the current value of the all
variable.
INPUT function:
The traditional use is the reread a character variable with a
numeric format, execute a character-to-numeric conversion.
The character to numeric conversion function;
INPUT (variable, informat-name)
The INPUT function converts the character variable to numeric
Salary=input (EMP_SALARY, dollar7.);
Character value
EMP_SALARY
$85,000
Numeric value
SALARY
85000
numeric value
PHONE
6778000
character value
PHONE
6778000
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?
Ans: I can use the contents Procedure of all in the
libname and see all the variable name and formats of
each data set
EG:
PROC CONTENTS DATA=LIBREF._ALL_;
RUN;
70. How would you keep SAS from overlaying the SAS set with
its sorted version?
Ans: By creating a new dataset after sorting by specifying
Out = new sas dataset
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
WHERE (VARIABLE NAME) LIKE A%;
Or
WHERE (VARIABLE NAME =: A;
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
PROC FREQ:
73. Code the table statement for a single-level (most common)
frequency.
Ans
The statement for single-level.
DATA MAR.FREQTEST;
SET BAS.AMPERS;
PROC FREQ DATA =MAR.FREQTEST;
TABLE AGE;
RUN;
74. Code the table statement to produce a multi-level
frequency.
Ans:
The statement for multilevel.
DATA MAR.FREQTEST;
SET BAS.AMPERS;
PROC FREQ DATA =MAR.FREQTEST;
TABLE AGE * gender;
RUN;
PROC MEANS:
77. Code a PROC MEANS that shows both summed and averaged
output of the data.
78. Code the option that will allow MEANS to include missing
numeric data to be included in the report.
79. Code the MEANS to produce output to be used later.
80. Do you use PROC REPORT or PROC TABULATE? Which do you
prefer? Explain.
MERGING/UPDATING :
81. What happens in a one-on-one merge? When would you use
one?
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.
82.
83.
What is the problem with merging two data set that have
variable with the same name but different data?
Ans:The second data set value will overwrite the value
of the first data set.
84.
When would you choose to MERGE two data sets together and
when would you SET two data sets?
Ans: If we want to create a dataset as an exact copy of
The old dataset without any bothering about which
Dataset is going to contribute to the new dataset
Then we will use set statement.
If we want to control the contribution of the old
Datasets to the new dataset then we will use the
Merge statement
85.
86.
87.
89.
90.
MACRO:
91.
92.