SAS Programming Fundamentals

Quiz covering SAS data steps, procedures, macro language, and built-in functions.

20 Questions Published

Questions

Question 1 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 2 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 3 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 4 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 5 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 6 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 7 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 8 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 9 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 10 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 11 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
Question 12 Multiple Choice (Single Answer)

How will you define the list of variables to be printed in the PRINT procedure?

  1. Weight statement
  2. Var statement
  3. Class statement
  4. By statement
Question 13 Multiple Choice (Single Answer)

You have to sort the dataset Temp by the values of salary in descending order. SORT procedure is given below. Find out the missing statement? Data temp; Infile datalines; Input empname $ salary; Datalines; AAA 25000 BBB 45000 CCC 36000 DDD 47000 ; Proc sort data=temp; <<<<<<>>>>>>>>>; Run;

  1. by descending salary
  2. by salary descending
  3. by salary ascending
  4. by salary
Question 14 Multiple Choice (Single Answer)

How can you assign a value from a datastep to a macro variable?

  1. Using Symget function
  2. Using Symput function
  3. Using Assign function
  4. Using Sysfunc function
Question 15 True/False

Can we use title statement inside Proc SQL?

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

What is the value of x in the following code? %let a=2; %let c=3; %let x=a + c;

  1. 5
  2. Error in the code
  3. 2 + 3
  4. 2 + 3 ;
Question 17 Multiple Choice (Single Answer)

What is the value of z? z=weekday(today()); Today being Wednesday, 30 September 2009

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

What are the different classes of tokens available in SAS?

  1. Literals, Numbers, Strings and Symbols
  2. Literals, Numbers, Names and Special Characters
  3. Literals, Characters, Special Characters and Symbols
  4. Characters and Numbers only
Question 19 Multiple Choice (Single Answer)

What is the use of macro function %SYSFUNC?

  1. Used to execute SAS Functions
  2. Used to execute SAS Statements
  3. Used to pass parameters to a macro function
  4. All of the above
Question 20 Multiple Choice (Single Answer)

In Proc SQL, Index can be created on tables and views. State whether the statement is true or false. Also classify the index types in Proc SQL?

  1. True, Simple and Complex
  2. False, Simple and Composite
  3. True, Simple and Composite
  4. False, Simple and Complex