INTERVIEW QUESTIONS
1. What SAS statements would you code to read an external raw data file to a DATA
step?
Ans: Infile and Input statements are used to read external raw data file to a Data
Step.
2. How do you read the variable that you need?
Ans: using INPUT statement.
3. How would you prevent SAS from reading the next record if the last variable didn’t
have a value?
Ans: MISS OVER option in the INFILE statement
4. 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: using DATA _NULL_
5. What statement do you code to tell SAS that it is to write to an external file?
Ans: File and Put statements
6. When looking for the data contained in a character string of 150 bytes, which
function is the best to locate that data: scan or index?
Ans: Scan
7. 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: Keep options or Keep statement
8. How would you delete duplicate observation?
Ans: noduprecs or noduplicates option in the proc sort statement
9. How would you code a merge that will keep only the observation that have matches
from both sets?
Ans: By using the IN internal variable in the merge statement.
10. How would you create a data set with 1 observation and 30 variables from a data set
with 30 observations and 1Variable?
Ans: Transpose Procedure
11. 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_
12. 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
13. What do the PUT and INPUT function do?
Ans: The INPUT function converts the character variable to numeric
The PUT function converts the numeric variable to character
14. How would you delete duplicate data values?
Ans: Nodupkey
15. What is the difference between: X=a+b+c+d; and X=SUM (a, b, c, d) , if you have
the missing values;? Write the code?
Ex: a=20, b=. , c=40, d=60
Ans: If we use SUM (a, b, c, d) it will ignore the missing Values if any and compute
the sum.
For Eg: SUM(20,.,40,60)=120
X=1+.+2+3 = MISSING.
16. 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: PROC CONTENTS
17. How would you keep SAS from overlaying the SAS set with its sorted version?
Ans: By creating a new dataset using Out = new sas dataset
18. In PROC PRINT, can you print only data values that begin with the letter “A”
Ans: WHERE (VARIABLE NAME) LIKE ‘A%’;
19. How would you combine 3 or more tables with different structures?
Ans: using Merge statement
20. What does index function do?
Ans:It writes specific character position in the character string
21. The following program is submitted. Which values are stored in the output data set?
data WORK.TEST;
input Name $ Age;
datalines;
John +35
;
run;
A. Name Age
------------------------
John 35
B. Name Age
------------------------
John (missing value)
C. Name Age
-------------------------
(missing value) (missing value)
D. The DATA step fails execution due to data errors.
Ans: A
22. If The following SAS program is submitted, which one of the following PRINT
procedure steps correctly applies the format?
proc format;
value score 1 - 50 = 'Fail'
51 - 100 = 'Pass';
run;
A. proc print data = SASUSER.CLASS;
var test;
format test score;
run;
B. proc print data = SASUSER.CLASS;
var test;
format test score.;
run;
C. proc print data = SASUSER.CLASS format = score;
var test;
run;
D. proc print data = SASUSER.CLASS format = score.;
var test;
run;
Ans: B
23. The SAS data set WORK.INPUT contains 10 observations, and includes the
numeric variable Cost.
The following SAS program is submitted to accumulate the total value of Cost for the 10
observations:
data WORK.TOTAL;
set WORK.INPUT;
<insert code here>
Total=Total+Cost;
run;
Which statement correctly completes the program?
A. keep Total;
B. retain Total 0;
C. Total = 0;
D. If _N_= 1 then Total = 0;
Ans: B
24. The following SAS program is submitted, What is the value of Char2?
data WORK.TEMP;
Char1='0123456789';
Char2=substr(Char1,3,4);
run;
A. 23
B. 34
C. 345
D. 2345
Ans: D
25. Which option in the PROC EXPORT procedure overwrites an existing file?
A. NEW
B. OVERWRITE
C. REPLACE
D. KEEP
Ans: C