SAS Programming Fundamentals
A quiz covering core SAS programming concepts including DATA steps, procedures, functions, macros, and data manipulation techniques.
Questions
What is the value stored in the variable x? Data test; name = ’TATA CONSULTANCY SERVICES’; b = ’C’; x = INDEX (name, b); Run;
- 2
- 23
- 6
- 5
What is the use of %INCLUDE statement in a program?
- Includes external files
- Includes SAS datasets
- Includes variables from other datasets
- All of the above
What is the SAS data value of 01-Jan-1960?
- 21916
- 1
- 0
- None of the above
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;
- 2
- 4
- 5
- 1
How are numeric and character missing values represented internally in SAS?
- numeric will be represented by blank and character will be represented by .
- both character and numeric will be represented as blanks
- numeric will be represented by . and character will be represented by blank
- numeric will be represented by . and character will be represented by NULL values
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;
- two, two, one
- two, three, one
- two, two, three
- two, two, two
Which date function advances a date, time or date/time value by a given interval?
- INTCK
- INTNX
- INTCX
- INTNK
How many observations will be there in the output dataset TEMP? Data temp; Set test (firstobs=50 obs=450); Run;
- 450
- 401
- 400
- 500
Which of the following can be used to read numeric values that contain numeric values and commas into a SAS dataset?
- comma. informat
- dollar. format
- comma. format
- w.d informat
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 ;
- 2
- 3
- 1
- 0
At compile time when an external file is read, what items are created?
- Program data vector (PDV) and Descriptor portion
- Input buffer, Program data vector (PDV) and Descriptor portion
- Input buffer and Descriptor portion
- None of the above
What does the line hold specifier single trailing(@) do when used in an input statement?
- holds the input record for the next INPUT statement to read in the same iteration of the DATA step
- holds the input record for the next INPUT statement to read across further iterations of the DATA step
- holds the input record for the current input statement to read across further iterations of the DATA step
- All of the above
What is the output of the following sum statement? X1=9, X2=4, X3=1 Z=sum(of X1-X3);
- 8
- 10
- 14
- 12
What is the use of PUT function in a DATA step?
- converts character to numeric
- onverts numeric to character
- writes the values to the output file
- None of the above
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?
- Proc tabulate
- Proc report
- Proc transpose
- Proc Invert
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?
- Proc freq; Tables country sales; Run;
- Proc freq; Table country sales; Run;
- Proc freq; Tables country * sales; Run;
- Proc freq; Table country * sales; Run;
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?
- 0
- 10
- 1
- 11
Which procedure can be used to see the descriptor portion of a dataset?
- Proc freq
- Proc print
- Proc datasets
- Proc contents
What is the length of variable a ? data temp; a=substr('joshi anand',1,3); run;
- 3
- 11
- 8
- 200
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;
- No Errors
- Error in the LIBNAME Statement
- Error in the Datalines statement
- Error in the infile statement