SAS Programming Fundamentals
Test your knowledge of SAS programming language including data steps, formats, informats, file handling, and basic procedures.
Questions
PROC SORT data = lib.temp out = temp2; By subjid; Run; In which library temp2 is made?
- work
- sasuser
- lib
- syntax error
options obs = 500; Data TEMP; Set test(firstobs = 75); Run; What will be the number of observations in temp dataset?
- 425
- 424
- 500
- 426
PROC SORT data = temp out=new; BY JOBCODE Descending SALARY; RUN; Temp DATASET What will be the output??
- "temp" dataset sorted by jobcode in desending order and salary in ascending order
- "temp" dataset sorted by jobcode in ascending order and salary in descending order
- "new" dataset sorted by jobcode in ascending order and salary in descending order
- "new" dataset sorted by jobcode in descending order and salary in ascending order
data temp; test = ‘X’; select(test); when(‘Y’) Name = ‘Ank’; when(‘X’) Name = ‘Ankur’; when(‘Z’) Name = ‘ ’; end; run; What is the output?
- Ank
- Ankur
- Missing
- 'Ankur'
data null; put ‘test’; run; Where will the ouput(test) be written?
- Syntax error
- Log
- In Last file opened
- In dataset null
What is true about ERROR variable?
- d.) Will have values “TRUE” or “FALSE”
- c.) Will have values “YES” or “NO”
- b.) This variable appears in output dataset
- a.) Can be used in assignments/calculation in datastep.
1----5----10--- (data in file ‘asa’) 03132000 data temp; infile ‘asa’; input date : MMDDYY10.; run; What will be stored in date?
- 02 January
- 02FEB2000
- 01022000
- 14682(number of days from 1st jan 1960)
data test; n=1; do while(n lt 6); n+1; end; run; What will be the value of n at the end of datastep?
- 7
- 6
- 5
- 8
data test; dat = '13MAR2000'd; format dat WEEKDATE.; run; What will be the value of dat in output dataset?
- 14682 (nmber of days from 1st jan 1960)
- 13MAR2000
- Monday, March 13, 2000
- Mon, March 13, 2000
data temp; set x; run; “missing code” data test; set y; run; What will be the missing code to reset the page number ?
- OPTIONS PAGENO = 1;
- OPTIONS RESET PAGENO = 1;
- OPTIONS RESET PAGENUMBER = 1;
- OPTIONS PAGENUMBER = 1;
DATA TEMP; Infile ‘filename’; Input ID $5 @; If ID = ‘RAMES’ then input Y $6 Z $10 @; else ID = ‘VIJAY’ then input R $2 @; Input age 5.; RUN; How many lines are read from input file during one execution of dataset?
- 2
- 1
- 3
- 4
How to write comma separated file?
- a.) FILE ‘filename’ dsd = ‘,’;
- b.) FILE ‘filename’ dlm = ‘ ’ dsd = ‘,’;
- c.) FILE ‘filename’ dlm = ‘,’;
- d.) FILE ‘filename’ csv = ‘,’;
1----5----10----15----(file ‘abc’) RAM,,20 RAJU,SHARMA,24 DATA temp; Infile ‘abc’ dsd; Input FNAME $ LNAME $ AGE; RUN; What will be the value of LNAME for 1st observation?
- ‘,’
- blank character value
- ‘SHARMA’
- syntax error
libname temp ‘abc.sds.as’; data temp.X1; set sasuser.X2; run; Which is the correct statement??
- In datastep input is read from temporary location and output is written to temporary location.
- .) In datastep input is read from permanent location and output is written to temporary location.
- In datastep input is read from temporary location and output is written to permanent location.
- In datastep input is read from permanent location and output is written to permanent location.
What is the output of DATE9. format?
- 11/31/2000
- 31/11/2000
- 31NOV2000
- 01NOVEMBER2000
data a; do X=1 to 3 ; input ID NAME $ AGE; end; datalines; 01 vivek 22 02 vital 25 03 rajes 20 ; What will be the number of observations and variables in output dataset??
- 3 and 3
- 1 and 3
- 1 and 4
- 3 and 1
What informat should be used to read the date variable in the flat file having the values like 02NOV2003?
- DATE9.
- MMDDYY8.
- MMDDYY10.
- none
Flat file structure is as below 1----5----10 $1,120 The following code is submitted. data temp; infile ‘file specification’; input salary 5; run; What would be the value of SALARY in the dataset TEMP
- blank value
- $1,120
- 2
- .
Format name or Informat name should end with a dot eg:DATE9.
- True
- False
data temp; length y $5; x=4; if x=4 then y='four'; else if x=7 then y='seven'; x=7; run; What would be the value of X and Y in the dataset temp?
- X=4 and Y= ‘seven’
- X=7 and Y=’seven’
- X=7 and Y=’four’
- X=4 and Y=’four’