SAS Programming Fundamentals

A quiz covering core SAS programming concepts including DATA steps, procedures, functions, macros, and data manipulation techniques.

20 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

What is the value stored in the variable x? Data test; name = ’TATA CONSULTANCY SERVICES’; b = ’C’; x = INDEX (name, b); Run;

  1. 2
  2. 23
  3. 6
  4. 5
Question 2 Multiple Choice (Single Answer)

What is the use of %INCLUDE statement in a program?

  1. Includes external files
  2. Includes SAS datasets
  3. Includes variables from other datasets
  4. All of the above
Question 3 Multiple Choice (Single Answer)

What is the SAS data value of 01-Jan-1960?

  1. 21916
  2. 1
  3. 0
  4. None of the above
Question 4 Multiple Choice (Single Answer)

How many variables will be there in the output dataset totmark? Data totmark; Set scores (keep=name mark1 mark2 ); Total = mark1 + mark2; Drop mark1 mark2; Run;

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

How are numeric and character missing values represented internally in SAS?

  1. numeric will be represented by blank and character will be represented by .
  2. both character and numeric will be represented as blanks
  3. numeric will be represented by . and character will be represented by blank
  4. numeric will be represented by . and character will be represented by NULL values
Question 6 Multiple Choice (Single Answer)

How does the following macros will resolve? What will be the output in log file? %let one=two; %let two=three; %let three=one; %put &one; %put &&one; %put &&&one;

  1. two, two, one
  2. two, three, one
  3. two, two, three
  4. two, two, two
Question 7 Multiple Choice (Single Answer)

Which date function advances a date, time or date/time value by a given interval?

  1. INTCK
  2. INTNX
  3. INTCX
  4. INTNK
Question 8 Multiple Choice (Single Answer)

How many observations will be there in the output dataset TEMP? Data temp; Set test (firstobs=50 obs=450); Run;

  1. 450
  2. 401
  3. 400
  4. 500
Question 9 Multiple Choice (Single Answer)

Which of the following can be used to read numeric values that contain numeric values and commas into a SAS dataset?

  1. comma. informat
  2. dollar. format
  3. comma. format
  4. w.d informat
Question 10 Multiple Choice (Single Answer)

How many observations will be there in the output dataset person? Data person; infile datalines; input name $ dept $ age; if age le 30; datalines; John Sales 38 Mary Brown Acctng 32 Spielberg Manager 28 ;

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

At compile time when an external file is read, what items are created?

  1. Program data vector (PDV) and Descriptor portion
  2. Input buffer, Program data vector (PDV) and Descriptor portion
  3. Input buffer and Descriptor portion
  4. None of the above
Question 12 Multiple Choice (Single Answer)

What does the line hold specifier single trailing(@) do when used in an input statement?

  1. holds the input record for the next INPUT statement to read in the same iteration of the DATA step
  2. holds the input record for the next INPUT statement to read across further iterations of the DATA step
  3. holds the input record for the current input statement to read across further iterations of the DATA step
  4. All of the above
Question 13 Multiple Choice (Single Answer)

What is the output of the following sum statement? X1=9, X2=4, X3=1 Z=sum(of X1-X3);

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

What is the use of PUT function in a DATA step?

  1. converts character to numeric
  2. onverts numeric to character
  3. writes the values to the output file
  4. None of the above
Question 15 Multiple Choice (Single Answer)

Dataset Temp contains 1 observation and 30 variables. Which procedure can be used to convert it into 30 observations with 1 variable in an efficient manner?

  1. Proc tabulate
  2. Proc report
  3. Proc transpose
  4. Proc Invert
Question 16 Multiple Choice (Single Answer)

I want to create a 2 way cross tabulation frequency based on Country and Sales using FREQ procedure. From the given options pick the correct code?

  1. Proc freq; Tables country sales; Run;
  2. Proc freq; Table country sales; Run;
  3. Proc freq; Tables country * sales; Run;
  4. Proc freq; Table country * sales; Run;
Question 17 Multiple Choice (Single Answer)

A SAS code has been executed and it has an error on the 10th line of the code. What will be the value of the automatic variable ERROR?

  1. 0
  2. 10
  3. 1
  4. 11
Question 18 Multiple Choice (Single Answer)

Which procedure can be used to see the descriptor portion of a dataset?

  1. Proc freq
  2. Proc print
  3. Proc datasets
  4. Proc contents
Question 19 Multiple Choice (Single Answer)

What is the length of variable a ? data temp; a=substr('joshi anand',1,3); run;

  1. 3
  2. 11
  3. 8
  4. 200
Question 20 Multiple Choice (Single Answer)

Find out the error in the following code? Libname output_dir “c:\mydocuments\output”; Data output_dir.test; Infile datalines dlm=’,’; Input name $ total; If total > 50; Datalines; Sharma,50 Thiyaga,90 Ashok,60 Run;

  1. No Errors
  2. Error in the LIBNAME Statement
  3. Error in the Datalines statement
  4. Error in the infile statement