SAS Programming Fundamentals

Test your knowledge of SAS programming language including data steps, formats, informats, file handling, and basic procedures.

20 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

PROC SORT data = lib.temp out = temp2; By subjid; Run; In which library temp2 is made?

  1. work
  2. sasuser
  3. lib
  4. syntax error
Question 2 Multiple Choice (Single Answer)

options obs = 500; Data TEMP; Set test(firstobs = 75); Run; What will be the number of observations in temp dataset?

  1. 425
  2. 424
  3. 500
  4. 426
Question 3 Multiple Choice (Single Answer)

PROC SORT data = temp out=new; BY JOBCODE Descending SALARY; RUN; Temp DATASET What will be the output??

  1. "temp" dataset sorted by jobcode in desending order and salary in ascending order
  2. "temp" dataset sorted by jobcode in ascending order and salary in descending order
  3. "new" dataset sorted by jobcode in ascending order and salary in descending order
  4. "new" dataset sorted by jobcode in descending order and salary in ascending order
Question 4 Multiple Choice (Single Answer)

data temp; test = ‘X’; select(test); when(‘Y’) Name = ‘Ank’; when(‘X’) Name = ‘Ankur’; when(‘Z’) Name = ‘ ’; end; run; What is the output?

  1. Ank
  2. Ankur
  3. Missing
  4. 'Ankur'
Question 5 Multiple Choice (Single Answer)

data null; put ‘test’; run; Where will the ouput(test) be written?

  1. Syntax error
  2. Log
  3. In Last file opened
  4. In dataset null
Question 6 Multiple Choice (Single Answer)

What is true about ERROR variable?

  1. d.) Will have values “TRUE” or “FALSE”
  2. c.) Will have values “YES” or “NO”
  3. b.) This variable appears in output dataset
  4. a.) Can be used in assignments/calculation in datastep.
Question 7 Multiple Choice (Single Answer)

1----5----10--- (data in file ‘asa’) 03132000 data temp; infile ‘asa’; input date : MMDDYY10.; run; What will be stored in date?

  1. 02 January
  2. 02FEB2000
  3. 01022000
  4. 14682(number of days from 1st jan 1960)
Question 8 Multiple Choice (Single Answer)

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?

  1. 7
  2. 6
  3. 5
  4. 8
Question 9 Multiple Choice (Single Answer)

data test; dat = '13MAR2000'd; format dat WEEKDATE.; run; What will be the value of dat in output dataset?

  1. 14682 (nmber of days from 1st jan 1960)
  2. 13MAR2000
  3. Monday, March 13, 2000
  4. Mon, March 13, 2000
Question 10 Multiple Choice (Single Answer)

data temp; set x; run; “missing code” data test; set y; run; What will be the missing code to reset the page number ?

  1. OPTIONS PAGENO = 1;
  2. OPTIONS RESET PAGENO = 1;
  3. OPTIONS RESET PAGENUMBER = 1;
  4. OPTIONS PAGENUMBER = 1;
Question 11 Multiple Choice (Single Answer)

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?

  1. 2
  2. 1
  3. 3
  4. 4
Question 12 Multiple Choice (Single Answer)

How to write comma separated file?

  1. a.) FILE ‘filename’ dsd = ‘,’;
  2. b.) FILE ‘filename’ dlm = ‘ ’ dsd = ‘,’;
  3. c.) FILE ‘filename’ dlm = ‘,’;
  4. d.) FILE ‘filename’ csv = ‘,’;
Question 13 Multiple Choice (Single Answer)

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?

  1. ‘,’
  2. blank character value
  3. ‘SHARMA’
  4. syntax error
Question 14 Multiple Choice (Single Answer)

libname temp ‘abc.sds.as’; data temp.X1; set sasuser.X2; run; Which is the correct statement??

  1. In datastep input is read from temporary location and output is written to temporary location.
  2. .) In datastep input is read from permanent location and output is written to temporary location.
  3. In datastep input is read from temporary location and output is written to permanent location.
  4. In datastep input is read from permanent location and output is written to permanent location.
Question 15 Multiple Choice (Single Answer)

What is the output of DATE9. format?

  1. 11/31/2000
  2. 31/11/2000
  3. 31NOV2000
  4. 01NOVEMBER2000
Question 16 Multiple Choice (Single Answer)

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??

  1. 3 and 3
  2. 1 and 3
  3. 1 and 4
  4. 3 and 1
Question 17 Multiple Choice (Single Answer)

What informat should be used to read the date variable in the flat file having the values like 02NOV2003?

  1. DATE9.
  2. MMDDYY8.
  3. MMDDYY10.
  4. none
Question 18 Multiple Choice (Single Answer)

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

  1. blank value
  2. $1,120
  3. 2
  4. .
Question 19 True/False

Format name or Informat name should end with a dot eg:DATE9.

  1. True
  2. False
Question 20 Multiple Choice (Single Answer)

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?

  1. X=4 and Y= ‘seven’
  2. X=7 and Y=’seven’
  3. X=7 and Y=’four’
  4. X=4 and Y=’four’