You are on page 1of 90

ATTENTION TO DETAIL

SAS certification author will correct the error in one answer choice but then introduce another error.
So when you select you answer make sure that none of the other answer choices can be the correct
answer.

Q. The SAS DATA SET temp has 100 observation and v1, v2, v3 and v4 variables. Which SAS DATA
STEP writes only the variables v1, v2 and v3 to both SAS data sets One and Two?

A. DATA one two;

SET temp;

KEEP v1 v2 v3

RUN;

B. DATA one (keep v1 v2 v3) two;

SET temp (keep = v1 v2 v3);

RUN;

C. DATA one two;

SET temp (keep v1 v2 v3);

RUN;

D. DATA one two;

SET temp (keep = v1 v2 v3);

RUN;

This looks like an easy question but if you dont pay attention, you might choose A as your answer
without realizing that a semicolon is missing in the KEEP statement. You might choose B or C as your
answer without realizing an equal to sign is missing in KEEP dataset option. The last choice D is the
correct answer, as it does not have any syntax error and does what the questions is asking. So before
you pick any answer, rule out all other options before making it your final choice.

PROCESS OF ELIMINATION (POE)


Following illustration will show how POE will improve your changes of guessing the right answer.

Q. The following SAS program is submitted.

DATA one;

ARRAY g[4,3] (1,2,3,4,5,6,7,8,9,10,11,12);

RUN;
What is the value of element g (3, 2)?

A. 8

B. 10

C. 1

D. 12

Now, just by looking at the data we know that element g (3, 2) should be somewhere in the middle of
the array definition. Lets now look at the answer choices, A can be the answer as it is somewhere in
the middle and so can choice B. But when you look at choice C and D, and you know g (3, 2) cannot
be extreme left or right values, so now you can remove these obviously two wrong choices. Now you
are left with choice A and B, now you can make an educated guess and choose either A or B as your
answer.

Sometime adding new line or spaces in your question can make finding answer easy. In our above
example suppose the array was declared as

ARRAY g [4, 3] (1, 2, 3,

4, 5, 6,

7, 8, 9,

10, 11, 12);

It is intuitive to understand here that there are 4 rows and 3 columns and question is asking for
element in 3rd row and 2nd column which is 8.

Base SAS 100


The following SAS program is submitted:
proc sort data=work.employee;
by descending fname;
proc sort data=work.salary;
by descending fname;
data work.empdata;
merge work.employee
work.salary;
by fname;
run;
Which one of the following statements explains why the program failed execution?
A. The SORT procedures contain invalid syntax.
B. The merged data sets are not permanent SAS data sets.
C. The data sets were not merged in the order by which they were sorted.
D. The RUN statements were omitted after each of the SORT procedures.
Click Comment link to get answer

Base SAS Example Question 1.1

How many of the below variable names will not produce errors in an assignment statement?

variable
var
1variable
var1
#var
_variable#

a) 0
b) 1
c) 3
d) 6

Base SAS Example Question 2.1


What keyword should be used in the blank below to list the dataset's variables in logical, not
alphabetical order?

proc contents data=air.organics ___;


run;

a) log
b) logical
c) varnum
d) var
C

Base SAS Example Question 3.1


Which of the below lines opens an external SAS file?

a) include 'd:\programs\sas\newprog.sas'
b) include 'd:\programs\sas\newprog.sas';
c) file 'd:\programs\sas\newprog.sas'
d) file 'd:\programs\sas\newprog.sas';
Answer is D.

Base SAS Example Question 4.1


Assume the variable 'Unit_Cost_Price' (numeric) contains both missing and non missing values.
What would the below output contain?

proc sort data=ecsql1.price_list;


by Unit_Cost_Price;
run;

a) A new dataset work.price_list is created with Unit_Cost_Price sorted in ascending order with
missing values at the bottom of the dataset
b) The dataset ecsql1.price_list is sorted with Unit_Cost_Price sorted in descending order with
missing values at the bottom of the dataset
c) A new dataset work.price_list is created with Unit_Cost_Price sorted in descending order with
missing values at the top of the dataset
d) The dataset ecsql1.price_list is sorted with Unit_Cost_Price sorted in ascending order with
missing values at the top of the dataset
Answer is D
Base SAS Example Question 5.1
Fill in the blank to output the first 5 observations from the filename col_inp.

data work.column_file;
infile col_inp _____;
input id 1 Name $ 3-16 Address $ 18-35;
where Name contains 'Ziggy';
run;

a) maxobs=5
b) obs=5
c) datalines=5
d) lines=5
Answer is b

Base SAS Example Question 6.1


dta work.il_corn;
set corn.state_data;
if state = 'Illinois';
run;

The keyword "data" is misspelled above. What happens to this program during the compilation
phase assuming "corn" is a valid libref?

a) The program fails due to syntax errors


b) The DATA step compiles but doesn't execute
c) The DATA step compiles and executes
d) None of the above
C

Base SAS Example Question 7.1


Which of the following is a valid statement about the VALUE range in the PROC FORMAT
procedure? It cannot be...

a) A single character or numeric value


b) A range of character values
c) A list of unique values separated by commas
d) A combination of character and numeric values
D

Base SAS Certification Example Question 8.1


By default, PROC MEANS computes how many of the below statistics?

Standard deviation
Range
Count
Minimum value
Variance
Mode

a) 2
b) 3
c) 4
d) None of the above
B
******************

PROC MEANS, PROC FREQ, and PROC SUMMARY procedures are a big part of the Base
SAS exam, and if you can answer these questions correctly you'll be well on your way to
achieving your certification! Be sure to leave your answer as a comment below and good luck!

Base SAS Certification Example Question 9.1


Which is false about the BODY, CONTENTS, and FRAME specifications when creating an HTML
file?

a) BODY is the name of an HTML file that contains the procedure output
b) FRAME is the name of an HTML file that integrates the table of contents and the body file
c) If you specify FRAME=, you must also specify CONTENTS=
d) None of the above
D

Base SAS Certification Example Question 10.1


Assume ecsql1.employee_donations has 6 observations, and qtr1 has 6 values listed below:

100
200
300
.
150
50

What is the value of donation_tot after the 5th DATA step iteration?

data work.donations;
set ecsql1.employee_donations (drop=qtr2-qtr4);
retain donation_tot 1000;
donation_tot + qtr1;
run;

a) 0
b) 750
c) 1750
d) Data step fails due to errors
Ans C

Base SAS Certification Sample Question 11.1


What should the blank line below read to be able to output the sum of Qtr_total by the variable
paid_by?

proc sort data=ecsql1.employee_donations out=work.employee_donations_sort;


by paid_by;
run;

data work.donations (keep=paid_by Qtr_total);


set work.employee_donations_sort;
by paid_by;
Qtr_total + Qtr1;
if _____________;
run;

a) last paid_by
b) paid_by.last
c) paid_by.last = 1
d) last.paid_by = 1
D

Base SAS Certification Sample Question 12.1


Which of the following is false about one-to-one merging?

a) The new dataset contains all variables from all input data sets
b) If there are same-named variables, the last dataset's variable replaces the earlier dataset's
variable
c) The new dataset contains the total number of observations in the smallest original dataset
d) None of the above
Ans - D
Options A,B and C are true for one to one merging.

Base SAS Certification Sample Question 13.1


Assume the variable employee_id in the ecsql1.salesstaff table has a length of 8, and the
program below runs without errors. Which of the below statements is true about the variable
employee_id2?

data work.sales_id (keep=employee_id2);


set ecsql1.salesstaff (keep=employee_id);
employee_id2 = put(employee_id,$9.);
run;

a) employee_id2 is a numeric variable with length 8


b) employee_id2 is a numeric variable with length 9
c) employee_id2 is a character variable with length 8
d) employee_id2 is a character variable with length 9
Ans is d

Base SAS Certification Sample Question 14.1


How many variables/observations will come from the below program?

data work.roth_ira;
start = 1000;
do year = 1 to 30;
savings + 5000;
do month = 1 to 12;
int = savings * (.05/12);
savings + int;
end;
output;
end;
run;

a) 4 variables, 12 observations
b) 4 variables, 30 observations
c) 5 variables, 12 observations
d) 5 variables, 30 observations
D. 5 variable and 30 observations

Base SAS Certification Sample Question 15.1


Which of the following is an invalid way to list array elements?

a) _NUMERIC_
b) _CHARACTER_
c) _ALL_
d) None of the above
Ans is D

Base SAS Certification Sample Question 16.1


Which of the following is standard data that may be read with either column input or formatted
input?

a) $1000
b) 10/3/2012
c) 10%
d) -1.54E-3
ANS-D

http://sascert.blogspot.in/2006/12/base-sas_116653578038985554.html

120 questions
1. Which function calculates the average of the variables Var1, Var2, Var3, and
Var4?
a. mean(var1,var4)
b. mean(var1-var4)
c. mean(of var1,var4)
d. mean(of var1-var4)

2. Within the data set Hrd.Temp, PayRate is a character variable and Hours is a
numeric variable. What happens when the following program is run?
data work.temp;
set hrd.temp;
Salary=payrate*hours;
run;
a. SAS converts the values of PayRate to numeric values. No message is
written to the log.
b. SAS converts the values of PayRate to numeric values. A message is
written to the log.
c. SAS converts the values of Hours to character values. No message is
written to the log.
d. SAS converts the values of Hours to character values. A message is
written to the log.

3. A typical value for the character variable Target is 123,456. Which statement
correctly converts the values of Target to numeric values when creating the
variable TargetNo?
a. TargetNo=input(target,comma6.);
b. TargetNo=input(target,comma7.);
c. TargetNo=put(target,comma6.);
d. TargetNo=put(target,comma7.);

4. A typical value for the numeric variable SiteNum is 12.3. Which statement
correctly converts the values of SiteNum to character values when creating the
variable Location?
a. Location=dept||'/'||input(sitenum,3.1);
b. Location=dept||'/'||input(sitenum,4.1);
c. Location=dept||'/'||put(sitenum,3.1);
d. Location=dept||'/'||put(sitenum,4.1);

5. Suppose the YEARCUTOFF= system option is set to 1920. Which MDY function
creates the date value for January 3, 2020?
a. MDY(1,3,20)
b. MDY(3,1,20)
c. MDY(1,3,2020)
d. MDY(3,1,2020)

6. The variable Address2 contains values such as Piscataway, NJ. How do you
assign the two-letter state abbreviations to a new variable named State?
a. State=scan(address2,2);
b. State=scan(address2,13,2);
c. State=substr(address2,2);
d. State=substr(address2,13,2);

7. The variable IDCode contains values such as 123FA and 321MB. The fourth
character identifies sex. How do you assign these character codes to a new
variable named Sex?
a. Sex=scan(idcode,4);
b. Sex=scan(idcode,4,1);
c. Sex=substr(idcode,4);
d. Sex=substr(idcode,4,1);

8. Due to growth within the 919 area code, the telephone exchange 555 is being
reassigned to the 920 area code. The data set Clients.Piedmont includes the
variable Phone, which contains telephone numbers in the form 919-555-1234.
Which of the following programs will correctly change the values of Phone?
a. data work.piedmont(drop=areacode exchange); set clients.piedmont;
Areacode=substr(phone,1,3); Exchange=substr(phone,5,3); if
areacode='919' and exchange='555' then scan(phone,1,3)='920'; run;
b. data work.piedmont(drop=areacode exchange); set clients.piedmont;
Areacode=substr(phone,1,3); Exchange=substr(phone,5,3); if
areacode='919' and exchange='555' then phone=scan('920',1,3); run;
c. data work.piedmont(drop=areacode exchange); set clients.piedmont;
Areacode=substr(phone,1,3); Exchange=substr(phone,5,3); if
areacode='919' and exchange='555' then substr(phone,1,3)='920'; run;
d. data work.piedmont(drop=areacode exchange); set clients.piedmont;
Areacode=substr(phone,1,3); Exchange=substr(phone,5,3); if
areacode='919' and exchange='555' then phone=substr('920',1,3); run;

9. Suppose you need to create the variable FullName by concatenating the values
of FirstName, which contains first names, and LastName, which contains last
names. What's the best way to remove extra blanks between first names and
last names?
a. data work.maillist; set retail.maillist; length FullName $ 40;
fullname=trim firstname||' '||lastname; run;
b. data work.maillist; set retail.maillist; length FullName $ 40;
fullname=trim(firstname)||' '||lastname; run;
c. data work.maillist; set retail.maillist; length FullName $ 40;
fullname=trim(firstname)||' '||trim(lastname);run;
d. data work.maillist; set retail.maillist; length FullName $ 40;
fullname=trim(firstname||' '||lastname); run;

10. Within the data set Furnitur.Bookcase, the variable Finish contains values
such as ash/cherry/teak/matte-black. Which of the following creates a subset of
the data in which the values of Finish contain the string walnut? Make the
403
search for the string case-insensitive.
a. data work.bookcase; set furnitur.bookcase; if index(finish,walnut) = 0;
run;
b. data work.bookcase; set furnitur.bookcase; if index(finish,'walnut') > 0;
run;
c. data work.bookcase; set furnitur.bookcase; if
index(lowcase(finish),walnut) = 0; run;
d. data work.bookcase; set furnitur.bookcase; if
index(lowcase(finish),'walnut') > 0;run;

Answers
1. Correct answer: d
Use a variable list to specify a range of variables as the function argument. When specifying
a variable list, be sure to precede the list with the word OF. If you omit the word OF, the
function argument might not be interpreted as expected.
2. Correct answer: b
When this DATA step is executed, SAS automatically converts the character values of
PayRate to numeric values so that the calculation can occur. Whenever data is automatically
converted, a message is written to the SAS log stating that the conversion has occurred.
3. Correct answer: b
You explicitly convert character values to numeric values by using the INPUT function. Be
sure to select an informat that can read the form of the values.
4. Correct answer: d
You explicitly convert numeric values to character values by using the PUT function. Be sure
to select a format that can read the form of the values.
5. Correct answer: c
Because the YEARCUTOFF= system option is set to 1920, SAS sees the two-digit year
value 20 as 1920. Four-digit year values are always read correctly
6. Correct answer: a
The SCAN function is used to extract words from a character value when you know the order
of the words, when their position varies, and when the words are marked by some delimiter.
In this case, you don't need to specify delimiters, because the blank and the comma are
default delimiters.
7. Correct answer: d
The SUBSTR function is best used when you know the exact position of the substring to
extract from the character value. You specify the position to start from and the number of
characters to extract.
8. Correct answer: c
404
The SUBSTR function replaces variable values if it is placed on the left side of an assignment
statement. When placed on the right side (as in Question 7), the function extracts a
substring.
9. Correct answer: b
The TRIM function removes trailing blanks from character values. In this case, extra blanks
must be removed from the values of FirstName. Although answer c also works, the extra
TRIM function for the variable LastName is unnecessary. Because of the LENGTH
statement, all values of FullName are padded to 40 characters.
10. Correct answer: d
Use the INDEX function in a subsetting IF statement, enclosing the character string in
quotation marks. Only those observations in which the function locates the string and returns
a value greater than 0 are written to the data set.
1. How many observations and variables does the data set below contain?

Name Sex Age


Picker M 32
Fletcher 28
Romano F .
Choi M 42

a. 3 observations, 4 variables
b. 3 observations, 3 variables
c. 4 observations, 3 variables
d. can't tell because some values are missing
2. How many program steps are executed when the program below is processed?
data user.tables;
infile jobs;
input date name $ job $;
run;
proc sort data=user.tables;
by name;
run;

proc print data=user.tables;


run;
a. three
b. four
c. five
d. six
3. What type of variable is the variable AcctNum in the data set below?
AcctNum Balance
3456_1 M
2451_2
Romano F
Choi M

a. numeric
b. character
c. can be either character or numeric
d. can't tell from the data shown
4. What type of variable is the variable Wear in the data set below?
Brand Wear
Acme 43
Ajax 34
Atlas .

A. numeric
B. character
C. can be either character or numeric
D. can't tell from the data shown
5. Which of the following variable names is valid?
a. 4BirthDate
b. $Cost
c. _Items_
d. Tax-Rate
6. Which of the following files is a permanent SAS file?
a. Sashelp.PrdSale
b. Sasuser.MySales
c. Profits.Quarter1
d. all of the above
7. In a DATA step, how can you reference a temporary SAS data set named
Forecast?
a. Forecast
b. Work.Forecast
c. Sales.Forecast (after assigning the libref Sales)
d. only a and b above

8. What is the default length for the numeric variable Balance?


Name Balance
Adams 105.73
Geller 107.89
Martinez 97.45
Noble 182.50

a. 5
b. 6
c. 7
d. 8
9. How many statements does the following SAS program contain?
proc print data=new.prodsale

label double;
var state day price1 price2; where state='NC';
label state='Name of State';
run;
a. three
b. four
c. five
d. six
10. What is a SAS data library?
a. a collection of SAS files, such as SAS data sets and catalogs
b. in some operating environments, a physical collection of SAS files
c. in some operating environments, a logically related collection of SAS
files
d. all of the above
Answers
1. Correct answer: c
Rows in the data set are called observations, and columns are called variables. Missing
values don't affect the structure of the data set.
2. Correct answer: a
When it encounters a DATA, PROC, or RUN statement, SAS stops reading statements and
executes the previous step in the program. The program above contains one DATA step and
two PROC steps, for a total of three program steps.
3. Correct answer: b
It must be a character variable, because the values contain letters and underscores, which
are not valid characters for numeric values.

4. Correct answer: a
It must be a numeric variable, because the missing value is indicated by a period rather
than by a blank.
5. Correct answer: c
Variable names follow the same rules as SAS data set names. They can be 1 to 32
characters long, must begin with a letter (AZ, either uppercase or lowercase) or an
underscore, and can continue with any combination of numbers, letters, or underscores.
6. Correct answer: d
To store a file permanently in a SAS data library, you assign it a libref other than the default
Work. For example, by assigning the libref Profits to a SAS data library, you specify that files
within the library are to be stored until you delete them. Therefore, SAS files in the Sashelp
and Sasuser libraries are permanent files.
7. Correct answer: d
To reference a temporary SAS file in a DATA step or PROC step, you can specify the onelevel name
of the file (for example, Forecast) or the two-level name using the libref Work (for
example, Work.Forecast).
8. Correct answer: d
The numeric variable Balance has a default length of 8. Numeric values (no matter how
many digits they contain) are stored in 8 bytes of storage unless you specify a different
length.
9. Correct answer: c
The five statements are
PROC PRINT statement (two lines long)
VAR statement
WHERE statement (on the same line as the VAR statement)
LABEL statement
RUN statement (on the same line as the LABEL statement).
10. Correct answer: d
Every SAS file is stored in a SAS data library, which is a collection of SAS files, such as
SAS data sets and catalogs. In some operating environments, a SAS data library is a
physical collection of files. In others, the files are only logically related. In the Windows and
UNIX environments, a SAS data library is typically a group of SAS files in the same folder or
directory.

1. If you submit the following program, how does the output look?
options pagesize=55 nonumber;
proc tabulate data=clinic.admit;
class actlevel;
var age height weight;
table actlevel,(age height weight)*mean;
run;
options linesize=80;
proc means data=clinic.heart min max maxdec=1;
var arterial heart cardiac urinary;
class survive sex;
run;
a. The PROC MEANS output has a print line width of 80 characters, but the
PROC TABULATE output has no print line width.
b. The PROC TABULATE output has no page numbers, but the PROC
MEANS output has page numbers.
c. Each page of output from both PROC steps is 55 lines long and has no
page numbers, and the PROC MEANS output has a print line width of 80
characters.
d. The date does not appear on output from either PROC step.
2. In order for the date values 05May1955 and 04Mar2046 to be read correctly,
what value must the YEARCUTOFF= option have?
a. a value between 1947 and 1954, inclusive
b. 1955 or higher
c. 1946 or higher
d. any value
3. When you specify an engine for a library, you are always specifying
a. the file format for files that are stored in the library.
b. the version of SAS that you are using.
c. access to other software vendors' files.
d. instructions for creating temporary SAS files.
4. Which statement prints a summary of all the files stored in the library named
Area51?
a. proc contents data=area51._all_ nods;
b. proc contents data=area51 _all_ nods;
c. proc contents data=area51 _all_ noobs;
d. proc contents data=area51 _all_.nods;
5. The following PROC PRINT output was created immediately after PROC
TABULATE output. Which SAS system options were specified when the report
was created?
1
10:03 Friday, March 17, 2000
Act
Obs ID Height Weight Level Fee
1 2458 72 168 HIGH 85.20
2 2462 66 152 HIGH 124.80
3 2501 61 123 LOW 149.75
4 2523 63 137 MOD 149.75
5 2539 71 158 LOW 124.80
6 2544 76 193 HIGH 124.80
7 2552 67 151 MOD 149.75
8 2555 70 173 MOD 149.75
9 2563 73 154 LOW 124.80
a. OBS=, DATE, and NONUMBER
b. PAGENO=1 and DATE
c. NUMBER and DATE only
d. none of the above
6. Which of the following programs correctly references a SAS data set named
SalesAnalysis that is stored in a permanent SAS library?
a. data saleslibrary.salesanalysis;
b. set mydata.quarter1sales;
c. if sales>100000;
d. run;
e. data mysales.totals;
f. set sales_99.salesanalysis;
g. if totalsales>50000;
h. run;
i. proc print data=salesanalysis.quarter1;
j. var sales salesrep month;
k. run;
l. proc freq data=1999data.salesanalysis;
m. tables quarter*sales;
n. run;
7. Which time span is used to interpret two-digit year values if the YEARCUTOFF=
option is set to 1950?
a. 1950-2049
b. 1950-2050
c. 1949-2050
d. 1950-2000
8. Assuming you are using SAS code and not special SAS windows, which one of
the following statements is false?
a. LIBNAME statements can be stored with a SAS program to reference the
SAS library automatically when you submit the program.
b. When you delete a libref, SAS no longer has access to the files in the
library. However, the contents of the library still exist on your operating
system.
c. Librefs can last from one SAS session to another.
d. You can access files that were created with other vendors' software by
submitting a LIBNAME statement.
9. What does the following statement do?
libname osiris spss 'c:\myfiles\sasdata\data';
a. defines a library called Spss using the OSIRIS engine
b. defines a library called Osiris using the SPSS engine
c. defines two libraries called Osiris and Spss using the default engine
d. defines the default library using the OSIRIS and SPSS engines
10. What does the following OPTIONS statement do?
options pagesize=15 nodate;
a. suppresses the date and limits the page size of the log
b. suppresses the date and limits the vertical page size for text output
c. suppresses the date and limits the vertical page size for text and HTML
output
d. suppresses the date and limits the horizontal page size for text output

Answers
1. Correct: answer: c
When you specify a system option, it remains in effect until you change the option or end
your SAS session, so both PROC steps generate output that is printed 55 lines per page with
no page numbers. If you don't specify a system option, SAS uses the default value for that
system option.
2. Correct answer: d
As long as you specify an informat with the correct field width for reading the entire date
value, the YEARCUTOFF= option doesn't affect date values that have four-digit years.
3. Correct answer: a
A SAS engine is a set of internal instructions that SAS uses for writing to and reading from
files in a SAS library. Each engine specifies the file format for files that are stored in the
library, which in turn enables SAS to access files with a particular format. Some engines
access SAS files, and other engines support access to other vendors' files.
4. Correct answer: a
To print a summary of library contents with the CONTENTS procedure, use a period to
append the _ALL_ option to the libref. Adding the NODS option suppresses detailed
information about the files.
5. Correct answer: b
Clearly, the DATE and PAGENO= options are specified. Because the page number on the
output is 1, even though PROC TABULATE output was just produced. If you don't specify
PAGENO=, all output in the Output window is numbered sequentially throughout your SAS
session.
6. Correct answer: b
Librefs must be 1 to 8 characters long, must begin with a letter or underscore, and can
contain only letters, numbers, or underscores. After you assign a libref, you specify it as the
first element in the two-level name for a SAS file.
7. Correct answer: a
The YEARCUTOFF= option specifies which 100-year span is used to interpret two-digit year
values. The default value of YEARCUTOFF= is 1920. However, you can override the default
and change the value of YEARCUTOFF= to the first year of another 100-year span. If you
specify YEARCUTOFF=1950, then the 100-year span will be from 1950 to 2049.
8. Correct answer: c
The LIBNAME statement is global, which means that librefs remain in effect until you modify
them, cancel them, or end your SAS session. Therefore, the LIBNAME statement assigns the
libref for the current SAS session only. You must assign a libref before accessing SAS files
that are stored in a permanent SAS data library.
51
9. Correct answer: b
In the LIBNAME statement, you specify the library name before the engine name. Both are
followed by the path.
10. Correct answer: b
These options affect the format of listing output only. NODATE suppresses the date and
PAGESIZE= determines the number of rows to print on the page.

1. As you write and edit SAS programs, its a good idea to


a. begin DATA and PROC steps in column one.
b. indent statements within a step.
c. begin RUN statements in column one.
d. all of the above.
2. What usually happens when a syntax error is detected?
a. SAS continues processing the step.
b. SAS continues to process the step, and the SAS log displays messages abou
the error.
c. SAS stops processing the step in which the error occurred, and the SAS log
displays messages about the error.
d. SAS stops processing the step in which the error occurred, and the Output
window displays messages about the error.
3. A syntax error occurs when
a. some data values are not appropriate for the SAS statements that are
specified in a program.
b. the form of the elements in a SAS statement is correct, but the elements are
not valid for that usage.
c. program statements do not conform to the rules of the SAS language.
d. none of the above.
4. How can you tell whether you have specified an invalid option in a SAS program?
a. A log message indicates an error in a statement that seems to be valid.
b. A log message indicates that an option is not valid or not recognized.
c. The message "PROC running" or "DATA step running" appears at the top of
the active window.
d. You can't tell until you view the output from the program.
5. Which of the following programs contain a syntax error?
a. proc sort data=sasuser.mysales;
b. by region;
c. run;
d. dat sasuser.mysales;
e. set mydata.sales99;
f. run;
g. proc print data=sasuser.mysales label;
h. label region='Sales Region';
i. run;
j. none of the above.
6. What does the following log indicate about your program?
proc print data=sasuser.cargo99
var origin dest cargorev;
22
76
ERROR 22-322: Syntax error, expecting one of the following:
;, (, DATA, DOUBLE, HEADING, LABEL,
N, NOOBS, OBS, ROUND, ROWS, SPLIT, STYLE,
UNIFORM, WIDTH.
ERROR 76-322: Syntax error, statement will be ignored.
11 run;
a. SAS identifies a syntax error at the position of the VAR statement.
b. SAS is reading VAR as an option in the PROC PRINT statement.
c. SAS has stopped processing the program because of errors.
d. all of the above
Answers
1. Correct answer: d
Although you can write SAS statements in almost any format, a consistent layout enhances
readability and enables you to understand the program's purpose. It's a good idea to begin
DATA and PROC steps in column one, to indent statements within a step, to begin RUN
statements in column one, and to include a RUN statement after every DATA step or PROC
step.
2. Correct answer: c
Syntax errors generally cause SAS to stop processing the step in which the error occurred.
When a program that contains an error is submitted, messages regarding the problem also
appear in the SAS log. When a syntax error is detected, the SAS log displays the word
ERROR, identifies the possible location of the error, and gives an explanation of the error.
3. Correct answer: c
Syntax errors are common types of errors. Some SAS system options, features of the Editor
window, and the DATA step debugger can help you identify syntax errors. Other types of
errors include data errors, semantic errors, and execution-time errors.
4. Correct answer: b
When you submit a SAS statement that contains an invalid option, a log message notifies you
that the option is not valid or not recognized. You should recall the program, remove or replace
the invalid option, check your statement syntax as needed, and resubmit the corrected
program.
5. Correct answer: b
The DATA step contains a misspelled keyword (dat instead of data). However, this is such a
common (and easily interpretable) error that SAS produces only a warning message, not an
error.
6. Correct answer: d
Because there is a missing semicolon at the end of the PROC PRINT statement, SAS interprets VAR
as an option in PROC PRINT and finds a syntax error at that location. SAS
stops processing programs when it encounters a syntax error.

Q1) Which one of the following is the value of the variable c in the output data
set?

data work.one;

a = 2;

b = 3;

c = a ** b;
run;

A) 6
B) 9
C) 8
D) None of the above

Solution: (C)

** is an exponential operator.

so c= a **b = 2**3 = 8

Q2) Which one of the following statement cant be part of PROC FREQ?

A) OUTPUT

B) WEIGHT

C) SET

D) Tables

E) None of the above

Solution: (C)

Look at the syntax of PROC FREQ, there is not SET statement required.

PROC FREQ <options> ;

BY variables ;

EXACT statistic-options </ computation-options> ;


OUTPUT <OUT=SAS-data-set> options ;

TABLES requests </ options> ;

TEST options ;

WEIGHT variable </ option> ;

RUN;

Q3) We have submitted the following PROC SORT step, which generates an
output data set.

proc sort data = AV.employee out = employee;

by Designation;

run;

In which library is the output data set stored?

A) Work

B) AV

C) SASHELP

D) SASUSER

Solution: (A)
If we are not providing library name explicitly then it will automatically refer to
temporary library WORK.

Question Context Q4 Q7
Below are the two tables:

Q4) How many variables would be in table AV after executing the below SAS
program?

data AV;

merge Employee Salary;

by name;

totsal + salary;

run;

A) 3

B) 4

C) 5
Solution: (B)

If we are using any variable name within data step program it will automatically get
created in output data set. Here, Three unique variables in both the tables are name,
age, salary and one more variable created within dataset totsal.

Q5) After executing below SAS program, how many observations would be AV
dataset?

data AV;

merge employee (in=ine) salary(in=ins);

by name;

run;

A) 4

B) 2

C) 1

D) 6

Solution: (D)

Above you look at input data sets, there is a one-to-many relationship between
Employee and Salary. To know more about merging in SAS, click here.

Q6) After executing below SAS program, how many observations would be in
AV dataset?
data AV;

merge employee (in=ine) salary(in=ins);

by name;

if ins=0;

run;

A) 4

B) 2

C) 1

D) 6

Solution: (B)

Here, we are talking about in variables and look at the below table to understand the

value of in variables:

In this program, we are looking for observations where ins = 0 which means that
name values not available in table Salary. In above table, you can see that only two
records satisfy that criteria.

Q7) Which one of the following command will help us to rename the column
Salary to Compensation of table Salary?
A.

Data Salary (Rename (Salary = Compensation));

Set Salary;

run;

B.

Data Salary (Rename = (Salary = Compensation));

Set Salary;

run;

C.

Data Salary (Rename = (Salary == Compensation));

Set Salary;

run;

D. None of the above

Solution: (B)

Syntax to rename variable(s) in SAS is:

RENAME = (Old_Var1 = NewVar1 Old_Var2=New_Var2 Old_Var3=New_Var3 )


Q8) Which of the following statements is not correct about the program shown
below?

data AV;

do year=2000 to 2004;

Capital+5000;

capital+(capital*.10);

output;

end;

run;

A. The OUTPUT statement writes current values to the dataset immediately


B. In this case, last value for Year in the new data set is 2005
C. The OUTPUT statement overrides the automatic output at the end of the DATA
step
D. The DO loop performs 5 iterations

Solution: (B)

In above program, we are writing to output dataset before END statement which
means it will not write last value 2005 to output dataset so last value would be 2004.
If we remove OUTPUT statement, last value would be 2005.

Q9) How can you limit the variables written to output dataset in DATA STEP?

A. DROP
B. KEEP
C. RETAIN
D. VAR
E. Both A or B
F. Both A, B or C

Solution: (E)

Both DROP and KEEP can be used to limit the variables in the dataset.

The DROP= option tells SAS which variables you want to drop. If you place
the DROP= option on the SET statement, SAS drops the specified variables when
it reads the input data set and if you place the DROP= option on the DATA
statement, SAS drops the specified variables when it writes to the output data set.
The KEEP= option tells SAS which variables you want to keep. If you place
the KEEP= option on the SET statement, SAS keeps the listed variables when it
reads the input data set. On the other hand, if you place the KEEP= option on the
DATA statement, SAS keeps the specified variables when it writes to the output
data set.

Q10) Which of the following statements are used to read delimited raw data file
and create an SAS data set?

A. DATA and SET


B. DATA, SET and INFILE
C. DATA, SET and INPUT
D. DATA, INFILE and INPUT

Solution: (D)

SET can not be used to read raw data files. SET is used to read data from one or
more SAS dataset.

Question context Q11 Q12

Below is the data from a csv file Emp.csv

Employee id,Gender,Name,DOB,Location,Salary,ManagerEmp ID

This dataset is about company employee

101,M,John,12/1/1995,Delhi,350000,101

102,F,Sangeeta,7/4/1980,Delhi,450000,103
103,F,Mary,3/5/1973,Mumbai,500000,101

104,M,Richard,6/25/1975,Mumbai,750000,101

105,M,Fredrick,8/20/1990,Delhi,320000,101

And, following code is used to read the filenamed EMP.

Q11) What will be the output if we run the below SAS statements to read
emp.csv file?

data WORK.EMP;

infile'C:\AV\Skilltest\Emp.csv'dlm=',' ;

input

Employee_id $

Gender $

Name $

DOB

Location $

Salary

Manager_Emp_ID;

run;
A.

B.

C.

D. None of the above

Solution: (C)

INFILE statement start reading a file from first line of CSV and it can be header row
also so we need to mention start row explicitly.

Q12) Which option will be added to infile statement to read a dataset from the
record with employee name John?

data WORK.EMP;

infile'C:\AV\Skilltest\Emp.csv'dlm=',' ;

input

Employee_id $
Gender $

Name $

DOB

Location $

Salary

Manager_Emp_ID;

run;

A. rows=3

B. option= 3

C. firstobs=2

D. start=3

E. Start=2

F. firstobs=3

Solution: (F)

FIRSTOBS option can be used to explicity mention the start row to read. In above
table, first row is representing header, second row about table and data set is starting
with third row.

Q13) Below SAS statements are used to read file Emp.csv from third record
of csv file.
Code:

data WORK.EMP;

infile'C:\AV\Skilltest\Emp.csv'dlm=',' DSD firstobs =3;

input

Employee_id $

Gender $

Name $

DOB

Location $

Salary

Manager_Emp_ID;

run;

Output:

Now, which statement we should add to the above code to read date column
DOB correctly?
A. Date 360

B. In-format and format

C. Both A and B

D. None of the above

Solution: (B)

To read date column, we need to explicitly mention the format type of date and that
can be done using INFORMAT and FORMAT statements.

Question Context 14

In the snapshot below, you can see that variable Avg is in character format.

Q14) Which of the following statement will help to convert Avg to numeric
format?

A. Input(Avg, 5.2)

B. PUT(Avg,5.2)
C. INT(Avg,5.2)

D. Both A and C

Solution: (A)

INPUT() and PUT() are conversion function in SAS. INPUT() is used to convert text to
a number whereas PUT() to convert the number to text.

Question Context 15 17

Q15) The following SAS program is run on the above table Emp

proc print data = emp;

where Name like '_R%';

run;

How many records will it print?

A. 1

B. 2

C. 3

D. None of the above


Solution: (D)

Like operator acts as case sensitive and in above table there is no-one whose second
character of the name is capital R.

Q16) Which of the following statement will calculate the age of each employee
as on 05-Feb-2017?

A.

data emp;

set emp;

Age = yrdif(DOB,'05Feb2017'd,'Actual');

run;

B.

data emp;

set emp;

Age = yrdif(DOB,'05Feb2017','Actual');

run;

C.

data emp;
set emp;

Age = yrdiff(DOB,'05Feb2017','Actual');

run;

D. None of the above

Solution: (A)

In SAS, date string is always followed by d to act as date.

Q17) If you submit the following program on above data set, which variables
appear in table Emp?

data emp(drop=Manager_EMP_ID Salary);

set emp (keep=Manager_EMP_ID Employee_ID Salary);

if Manager_Emp_ID=101 and Salary >45000;

Age = yrdif(DOB,'05Feb2017'd,'Actual'd);

run;

A. Employee_Id, Gender, Name, Location, Salary, DOB, Manager_Emp_ID

B. Employee_Id, Gender, Name, Location, Salary, DOB, Manager_Emp_ID, Age

C. Employee_ID

D. Employee_ID, Age
E. Employee_ID, Age, DOB

Solution: (D)

We have only three variables from input dataset Manager_EMP_ID,Employee_ID,


Salary and two new variables introduced DOB and Age. In Data statement, we
have dropped two (Manager_EMP_ID and Salary) out of these five variables. Now
variables in output dataset Employee_ID, Age, and DOB.

Question context 18

Below is the csv file class.csv for marks of students in different subjects:

Name,Gender,Location,English,Maths,Hindi,Sanskrit

Mohan,M,Banglore,50,60,70,80

Ramesh,M,Banglore,45,50,65,89

John,M,Washington,68,,,88

Kathy,F,Washington,89,55,85,83

George,M,Washington,43,45,95,84

Lisa,F,Washington,76,85,,86

Venkat,M,Banglore,68,90,78,92

Srimohan,M,Banglore,59,56,80

Preet,F,Banglore,81,95,85,96

Lindsy,F,Washington,66,75,78,82

Below code is used to read the file class.csv into a SAS dataset table named class.
data WORK.class;

infile'C:\AV\Skilltest\ClassScore.csv'dlm=','firstobs=2;

input

Name $

Gender $

Location $

English

Maths

Hindi

Sanskrit;

run;

Above code gives the below output:

Q18) In the above output, you can see following issues:


Marks are not under right column heading like John marks inSanskrit has shifted
to Maths
The total number of observation is 7 only.

Which of the following command can be used with infile statement to remove
these errors?

A. MISSING

B. MISSOVER

C. DSD

D. Both A and C

E. Both B and C

Solution: (E)

Whenever a read a delimited file using infile statement and if the file has two or more
delimiter together (n value between them) or last column data is missing then it takes
the next possible value as an input for that column. And, the next possible value can
be other column data of same row or next line also.

Now, to avoid these reading issues, we use DSD to prevent reading from next column
of the same row and MISSOVER for next line or observation.

Question context 19

Below is the table Class


Q19) Which of the following command will find the number of missing marks in
all variables of table Class.

A.

proc means data=class N;

run;

B.

proc means data=class N NMISS;

run;

C.

proc means data=class SUM N;

run;

D. Both B and C

Solution: (B)
Options with PROC MEANS:

N: Number of observations with a non-missing value of the analysis variable


MEAN: Mean (Average) of the analysis variables non-missing values
STD: Standard Deviation
MAX: Largest (Maximum) Value
MIN: Smallest (Minimum) Value
NMISS: Number of missing Values

Q20) Which of the following command will help to impute the missing value of
column Hindi with average marks of Hindi?

A)

Proc SQL;

Create table temp as Select *, mean(Hindi) as avg_score from Class;

quit;

Data class (drop= Hindi avg_score Rename=(Hindi_2=Hindi));

Set temp;

If Hindi=. Then Hindi_2=avg_score;

Else Hindi_2=Hindi;

run;

B)
Proc SQL;

Create table temp as Select *, mean(Hindi) asavg_score from Class;

quit;

Data class (drop= Hindi avg_score Rename=(Hindi_2=Hindi));

Set class;

If Hindi=. Then Hindi_2=avg_score;

Else Hindi_2=Hindi;

run;

C) Both A and B

D) None of the above

Solution: (A)

In the first option, we are creating a variable avg_score in the table temp and then
using this table data in data step to input missing values of HINDI whereas in option
second, we are using table class as an input data set for data step.

Question Context 21 24

Table-1
Product_I Proposed_Booking_Dat Qty_M Discount_Dolla
Location
D e T r

Delhi_NC
A201 12-Jan-17 4 10
R

A304 Chennai 12-Jan-17 5 20

A205 Mumbai 15-Jan-17 2 4

Delhi_NC
C406 17-Jan-17 8 5
R

Delhi_NC
C203 20-Jan-17 7 1
R

Z404 Mumbai 15-Jan-17 6 12

Table-2

Product_I Locatio Proposed_Booking_Dat Qty_M Discount_Dolla


D n e T r

A210 Mumbai 14-Jan-17 10 10

A310 Mumbai 14-Jan-17 8 20

A354 Delhi 18-Jan-17 5 4

C406 Delhi 17-Jan-17 8 5

C203 Delhi 20-Jan-17 7 1

Z514 Delhi 18-Jan-17 10 15

Table 3

Dollar
Date
Rate
12-Jan-
67.1
17

14-Jan-
67.2
17

15-Jan-
66.6
17

17-Jan-
67.2
17

18-Jan-
66.5
17

20-Jan-
66.8
17

Q21) Which of the following statements can be used to append the Table-1 and
Table-2 having a unique value of Product_ID?

A.

data work.merge_table NODUPKEY;

set table1 table2;

run;

B.

data work.merge_table;

set table1 table2;

run;
PROC SORT DATA = merge_table OUT = merge_table NODUPKEY;

by Product_ID;

run;

C.

data work.merge_table;

set table1 table2 nodupkey;

run;

PROC SORT DATA = merge_table OUT = merge_table;

by Product_ID ;

run;

D. none of the above

Solution: (B)

To remove duplicate records based on a variable or multiple variables, we use


NODUPKEY with PROC SORT or FIRST./ LAST. option to remove duplicate records.
For more detail on removing duplicate records, you can refer this link.
Q22) With cash crunch (due to demonetization) the company decided to
advance the proposed booking date by 2 months (keeping the day intact). Which
of the below SAS formula can be used to advance the date?

A.

data work.av_date;

set work.merge_table;

proposed_booking_date1=put(intnx('month',proposed_booking_date,day),date9.);

run;

B.

data work.av_date;

set work.merge_table;

proposed_booking_date1=put(intnx('month',proposed_booking_date,2,'s'),date9.)

run;

C.

data work.av_date;

set work.merge_table;
proposed_booking_date1=put(intnx('month',proposed_booking_date,sameday),date9

.);

run;

D.

data work.av_date;

set work.merge_table;

proposed_booking_date1=put(intnx('month',proposed_booking_date,1),date9.);

run;

Solution: (B)

Look, at the syntax of INTNX() function:

INTNX ( interval, from, n < , alignment > ) ;

The arguments to the INTNX function are as follows:

interval: is a character constant or variable that contains an interval name

from: is a SAS date value (for date intervals) or datetime value (for datetime
intervals)

n: is the number of intervals to increment from the interval that contains the from
value

alignment: controls the alignment of SAS dates, within the interval, used to identify
output observations. Allowed values are BEGINNING, MIDDLE, END, and
SAMEDAY/S.
In the second option, you can see that we have used the similar syntax to advance
the date value by 2 months.

Q23) If the following code will run, what will be the output?

data table_A (Drop = Location);

merge table1(in=Proposed_Booking_Date) table3(in=Date);

if Proposed_Booking_Date;

if Date then Discount_INR=Discount_Dollar*Dollar_Rate;

run;

A.

Product_ Proposed_Bokking_ Qty_ Discount_Do Dollar_R Discount_I


ID Date MT llar ate NR

A201 12-Jan-17 4 $10 67.1 671

A304 12-Jan-17 5 $20 67.2 1344

A205 15-Jan-17 2 $4 66.6 266.4

C406 17-Jan-17 8 $5 67.2 336

C203 20-Jan-17 7 $1 66.5 66.5

Z404 15-Jan-17 6 $12 66.8 801.6

B.
Product Proposed_Bokkin Dat Qty_ Discount_D Dollar_R Discount_
_ID g_Date e MT ollar ate INR

12-
Ja
A201 12-Jan-17 4 $10 67.1 671
n-
17

12-
Ja
A304 12-Jan-17 5 $20 67.2 1344
n-
17

15-
Ja
A205 15-Jan-17 2 $4 66.6 266.4
n-
17

17-
Ja
C406 17-Jan-17 8 $5 67.2 336
n-
17

20-
Ja
C203 20-Jan-17 7 $1 66.5 66.5
n-
17

15-
Ja
Z404 15-Jan-17 6 $12 66.8 801.6
n-
17

C.

Product_ID Qty_MT Discount_Dollar Dollar_Rate Discount_INR

A201 4 $10 67.1 671

A304 5 $20 67.2 1344

A205 2 $4 66.6 266.4

C406 8 $5 67.2 336


C203 7 $1 66.5 66.5

Z404 6 $12 66.8 801.6

Solution: (C)

IN variable does not appear in output dataset. Here, Proposed_Booking_Date and


Date are IN variables and we have dropped the variable Location in data step.

Q24) In Table-2, Location name Delhi has been wrongly put, need to replace
this with Delhi_NCR. Which of the following code will complete this task?

A.

data t2;

set TABLE2;

if Location="Delhi" then Location="Delhi_NCR";

run;

B.

data t2;

format location $10.;

set TABLE2;

if Location="Delhi" then Location="Delhi_NCR";


run;

C.

data t2;

length Location $10;

format location $10.;

set TABLE2;

if Location="Delhi" then Location="Delhi_NCR";

run;

D. Both B and C

E. Both A and B

F. None of the above

Solution: (D)

The length of field Location in table2 is 8 so first we need to change the format of
Location. Here in both options B and C, we have changed the length of field
Location.

Q25) [ True | False] Value of First. BY-variable and Last. By-variable can be same.

A. True

B. False
Solution: (A)

Yes, it is possible. In case of one unique value for BY variable then this record is the
first and last record as well.

Q26) Which is pointer control used to read multiple records sequentially?

A. @n

B. +N

C. /

D. All of the above

Solution: (C)

You can use one or more forward slash (/) line pointer controls in your INPUT
statements to tell SAS to advance to a new record before reading the next data
value.

Question Context 27 30

Table 5

Loan_ID Gender Name Dependents Education LoanAmount Property_Area Loan

LP001002 Male Dr.Kunal 0 Graduate 145 Urban Y

Mr.
LP001003 Male 1 Graduate 128 Rural N
Faizan

Miss.
LP001005 Female 0 Graduate 66 Urban Y
Swati
Miss. Not
LP001006 Female 0 120 Urban H
Deepika Graduate

Master
LP001008 Male 0 Graduate 141 Urban Y
Ankit

NOTE: The dataset has been loaded in SAS and table name is table5.

Q27) Categorical column may contain more than two distinct values. For
example, Married has two values, Yes and No. How will you find all the
distinct values present in the column Education?

A.

proc freq data=Table5;

tables Education;

run;

B.

proc means data=Table5;

var Education;

run;

C. Both A and B

D. None of the above

Solution: (A)
Proc Means is used to look at the frequency distribution of categories of a categorical
variable whereas PROC Means used to explore continuous variables.

Q28) How will you create an extra column Salutation?

Loan_ID Gender Name Salutation Dependents Education LoanAmount Property_

LP001002 Male Dr.Kunal Dr 0 Graduate 145 Urban

Mr.
LP001003 Male Mr 1 Graduate 128 Rural
Faizan

Miss.
LP001005 Male Miss 0 Graduate 66 Urban
Swati

Miss. Not
LP001006 Male Miss 0 120 Urban
Deepika Graduate

Master
LP001008 Male Master 0 Graduate 141 Urban
Ankit

A.

data Table5;

set Table5;

Salutation = scan(name, 1);

run;

B.

data Table5;

set Table5;
Salutation = scan(name, -1);

run;

C.

data Table5;

set Table5;

Salutation = scan(name, 0);

run;

data test2;

set Table5;

Salutation = scan(name, ,1);

run;

data test2;

set Table5;

Salutation = scan(name, .,1);


run;

Solution: (A)

Below is the syntax of function SCAN:

SCAN(string, count_words)

String: A constant string or variable have a string value

Count: is a nonzero numeric constant, variable, or expression that has an integer


value that specifies the number of the word in the character string that you want SCAN
to select

If count is positive, SCAN counts words from left to right in the character string.
If count is negative, SCAN counts words from right to left in the character string.

In above question, we need to extract the first word of string so value of count would
be 1 and string variable is name.

Q29) Which of the following command will help you to create the below table
AV (Exactly Similar) based on Table5?

AV

Loan_ID Loan_Status_Y Loan_Status_H Loan_Status_N

LP001002 1 0 0

LP001003 0 1 0

LP001005 1 0 0

LP001006 0 0 1

LP001008 1 0 0

A.
data AV;

Set table5;

if Loan_Status = "Y" then Loan_Status_Y = 1; else Loan_Status_Y = 0;

if Loan_Status = "N" then Loan_Status_N = 1; else Loan_Status_N = 0;

if Loan_Status = "H" then Loan_Status_H = 1; else Loan_Status_H = 0;

run;

B.

data AV;

Set table5;

Loan_Status_Y= (Loan_Status = "Y");

Loan_Status_N= (Loan_Status = "N");

Loan_Status_H= (Loan_Status = "H");

run;

C. Both A and B

D. None of the above

Solution: (D)
First of all, here we are creating dummy variables for variable Loan_Status (also
known as One Hot Encoding). Both Option A and B will create these dummy variables
but after execution of both program you will not be able to create exactly similar dataset
like AV because it will have more number of variables and the values of dummy
variables for Loan_Status_H and Loan_Status_N is swapped in output table AV.

Q30) Which of the following SAS program will help you understand the
relationship between two variables Education and Loan_Status?

A.

Proc Freq data=table5;

tables Education*Loan_Status;

run;

B.

Proc Freq data=table5; ?

tables Education Loan_Status;


run;

C.

Proc Univariate data = table5;

var Education Loan_Status;

run;

D.

Proc Univariate data = table5;

var Education*Loan_Status;

run;

Solution: (A)

Above, we are trying to create a two-way table based on two categorical variables
Education and Loan_Status. And to create two-way table, we need to place * in
between them. If we will separate the variable name by space then this will create two
individual frequency distributions for both the variables.

Q31) [True | Flase] The two programs below will return same output.

Program1

data AV (Drop= LoanAmount);


set table5;

charge=LoanAmount *0.4;

run;

Program2

data AV;

set table5 (Drop= LoanAmount);

charge=LoanAmount *0.4;

run;

A. True

B. False

Solution: (B)

In the first program, we have LoanAmount in input data set so there would be values
0.4*LoanAmount in Charge column whereas, in the second program, we have
dropped the variable LoanAmount so the value of column Charge would be missing
because we do not have variable LoanAmount.

Q32) Which of the following statement can be used to accumulate the value of
the variable in a Data Step?

A. SET

B. RETAIN
C. UPDATE

D. SUM

Solution: (B)

The RETAIN statement simply copies retaining values by telling the SAS not to
reset the variables at the beginning of each iteration of the DATA step. If you would
not use retain statement then SAS would reset the variable at the beginning of each
iteration

Q33) Given the following SAS error log

44 data WORK.OUTPUT;

45 set SASHELP.CLASS;

46 BMI=(Weight*703)/Height**2;

47 where bmi ge 20;

ERROR: Variable bmi is not on file SASHELP.CLASS.

48 run;

Which of the following step, you will take to correct it?

A. Replace the WHERE statement with an IF statement

B. Change the ** in the BMI formula to a single *

C. Change bmi to BMI in the WHERE statement

Solution: (A)
We can not apply WHERE on derived or calculated variable(s) so we should use IF
for subsetting.

Q34) Which of the following statement can be used to transpose table Base to
table Transposed?

A.

data transposed;

set base;

array Qtr{3} Q:;

do i = 1 to 3;

Period = cat('Qtr',i);

Amount = Qtr{i};

output;

end;

drop Q1 Q2 Q3 i;
if Amount ne .;

run;

B.

proc transpose data = base out = transposed

(rename=(Col1=Amount) where=(Amount ne .)) name=Period;

by cust;

run;

C. Both A and B

D. None of the above

Solution: (C)

Both program can be used to transpose the data set, One is array approach whereas
in second method, we are using PROC Transpose.

Q35) [True | False] Where and IF always returns the same result.

A) True

B) False

Solution: (B)

One of the scenarios, we have discussed in question 35.


Q36) Which of the following PROC can be used to create Bubble, Scatter
and Histogram?

A. PROC SGPLOT

B. PROC UNIVARIATE

C. PROC PLOT

D. None of the above

Solution: (A)

PROC SGPLOT can be used to create all above-mentioned charts.

Question Context 37 38

Table6

Month Product1 Product2 Product3

Jan 30 38 39

Feb 35 43 47

Mar 68 70 78

Apr 18 26 26

May 25 31 33

Jun 29 36 40

Jul 34 38 47

Aug 34 37 43
Sep 36 43 51

Oct 34 36 43

Nov 32 34 40

Dec 33 43 44

Note: Above table Table6 is stored in WORK library

Q37) Which of the following command can be used to plot below chart?

A.

PROC SGPLOT DATA = Table6;

SERIES X = Month Y = Product1;

SERIES X = Month Y = Product2;

SERIES X = Month Y = Product3;


run;

B.

PROC SGPLOT DATA = Table6;

by Month;

Var Product1 Product2 Product3;

run;

C.

PROC SGPLOT DATA = Table6;

Line Month;

Var Product1 Product2 Product3;

run;

D. None of the above

Solution: (A)

Above, we are creating three series of line in a single chart and we dont have any
Line and BY statements in PROC SGPLOT.
Q38) Which of the following command can be used to plot below chart (Below
Product1 is represented on x-axis, Product2 on y-axis and Product3 as the size
of bubble)?

A.

proc plot data = Table6;

scatter X=Product1 Y=Product2 size= Product3

/fillattrs=(color = teal) datalabel = Month;

run;

B.

proc sgplot data = Table6;

bubble X=Product1 Y=Product2 size= Product3

/fillattrs=(color = teal) datalabel = Month;


run;

C.

proc sgplot data = Table6;

scatter X=Product1 Y=Product2 size= Product3

/fillattrs=(color = teal) datalabel = Month;

run;

D.

proc chart data = Table6;

scatter X=Product1 Y=Product2 size= Product3

/fillattrs=(color = teal) datalabel = Month;

run;

Solution: (B)

In bubble chart, we have three variables to visualize. One on x-axis, second one on y-
axis and last one as size of bubble. We can create Bubble chart in SAS using PROC
SGPLOT with Bubble statement.

Question Context 39 40

Below is the table of product inventory (SAS data set name is Table7)
Q39) Which of the following SAS program will remove the duplicate
observation(s) of ID and Area_Type. And, remove observation having the
lower magnitude of variable Volume?

A.

Proc Sort data=table7;

by ID Area_Type Descending Volume;

run;

Proc SORT Data=table7 out=table8 nodupkey;

by ID Area_Type;

run;

B.

Proc Sort data=table7;


by ID Area_TypeVolume Descending;

run;

Proc SORT Data=table7 out=table8 nodupkey;

by ID Area_Type;

run;

C.

Proc SORT Data=table7 out=table8 nodupkey;

by ID Area_TYPE Volume Descending;

run;

D. Both B and C

Solution: (A)

The basic problem with Option B and C is, Descending option is appearing after the
variable name which is not the right syntax. In option A, we are first sorting the data
set based on ID, Area_Type and Volume (Descending) then again writing a PROC
SORT to remove duplicate records based on ID and Area_Type.

Q40) Which of the following program will help to bin the variable volume (Adding
one more variable to Table7, Volume_Bucket)?

A.

Data table7;
set table7;

select (Volume);

when (le 30) Volume_Bucket="A";

when (le 60) Volume_Bucket="B";

otherwise Volume_Bucket="C";

end;

run;

B.

Data table7;

set table7;

if Volume < 30 then Volume_Bucket ="A";

Else if Volume <60 then Volume_Bucket="B";

Else Volume_Bucket="C";

run;

C. Both A and B

D. None of the above


Solution: (B)

Select statement works with exact value, it does not compare like greater than or less
than so here IF statement will do the task.

Q1. The following SAS program is submitted:

data work.total;
set work.salary(keep = department wagerate);
by department;
if first.department then payroll = 0;
payroll + wagerate;
if last.department;
run;

The SAS data set named WORK.SALARY contains 10 observations for each
department, currently ordered by DEPARTMENT.

Which one of the following is true regarding the program above?


A. The BY statement in the DATA step causes a syntax error.
B. FIRST.DEPARTMENT & LAST.DEPARTMENT are variables in WORK.TOTAL
dataset.
C. The values of the variable PAYROLL represent the total for each department in
the WORK.SALARY data set.
D. The values of the variable PAYROLL represent a total for all values of
WAGERATE in the WORK.SALARY data set.

Answer: C. For every BY group we get the sum of wagerate in the Payroll variable
for each department.

Q2. The following SAS program is submitted:

data test;
set sasuser.employees;
if 2 le years_service le 10 then
amount = 1000;
else if years_service gt 10 then
amount = 2000;
else
amount = 0;
amount_per_year = years_service / amount;
run;

Which one of the following values does the variable AMOUNT_PER_YEAR contain if
an employee has been with the company for one year?
A. 0
B. 1000
C. 2000
D. . (missing numeric value)

Answer : D (missing). It returns missing value as amount will be 0.


SAS Log: NOTE: Mathematical operations could not be performed at the following
places. The results of the operations have been set to missing values.

Q3. The contents of the raw data file NAMENUM are listed below:
--------10-------20-------30
Joe xx

The following SAS program is submitted:


data test;
infile 'namenum';
input name $ number;
run;

Which one of the following is the value of the NUMBER variable?


A. xx
B. Joe
C. . (missing numeric value)
D. The value can not be determined as the program fails to execute due to errors.

Answer : C. It is because number is defined as a numeric variable so it is expecting a


numeric value but it reads xx, so number will be a missing value.

Q4. How many of the following variable names will not produce errors in an
assignment statement?

variable
var
1variable
var1
#var
_variable#

A. 0
B. 1
C. 3
D. 6
Answer : C ; variable var var1. A variable cannot start with numeric or special
characters except _. You also cannot use special characters anywhere in the name
either though numeric values are allowed.

Q5. Suppose the variable 'Unit_Cost_Price' (numeric) contains both missing and non
missing values. What would the following code return?

proc sort data=ecsql1.price_list;


by Unit_Cost_Price;
run;

A. A new dataset work.price_list is created with Unit_Cost_Price sorted in ascending


order with missing values at the bottom of the dataset
B. The dataset ecsql1.price_list is sorted with Unit_Cost_Price sorted in descending
order with missing values at the bottom of the dataset
C. A new dataset work.price_list is created with Unit_Cost_Price sorted in
descending order with missing values at the top of the dataset
D. The dataset ecsql1.price_list is sorted with Unit_Cost_Price sorted in ascending
order with missing values at the top of the dataset

Answer : D. It is because missing values are considered as lowest values (ascending


order; they will be top of the data set)

Q6. The following SAS program is submitted:

dta work.il_corn;
set corn.state_data;
if state = 'Illinois';
run;
The keyword "data" is misspelled above. What happens to this program during the
compilation phase assuming "corn" is a valid libref?

A. The program fails due to syntax errors


B. The DATA step compiles but doesn't execute
C. The DATA step compiles and executes
D. None of the above

Answer : C. It compiles and executes as SAS assumed that the 'dta' was data. But it
leaves a warning in log window.
The log shows the following warning :
WARNING 1-322: Assuming the symbol DATA was misspelled as dta.
141 run;
Q7. Which of the following is a valid statement about the VALUE range in the PROC
FORMAT procedure? It cannot be...

A. A single character or numeric value


B. A range of character values
C. A list of unique values separated by commas
D. A combination of character and numeric values

Answer : D.

Q8. How many of the following statistics that PROC MEANS computes as default statistics?

Standard deviation
Range
Count
Minimum value
Variance
Mode

A. 2
B. 3
C. 4
D. None of the above

Answer : B. By default, PROC MEANS calculates count, mean, standard deviation,


minimum and maximum value.

Q9. The following SAS program is submitted:

data work.totalsales (keep = monthsales{12} );


set work.monthlysales (keep = year product sales);
array monthsales {12} ;
do i=1 to 12;
monthsales{i} = sales;
end;
run;
The data set named WORK.MONTHLYSALES has one observation per month for
each of five years for a total of 60 observations.

Which one of the following is the result of the above program?


A. The program fails execution due to data errors.
B. The program fails execution due to syntax errors.
C. The program executes with warnings and creates the WORK.TOTALSALES data
set.
D. The program executes without errors or warnings and creates the
WORK.TOTALSALES data set.

Answer : B. The syntax issue lies in this line of code - keep = msales{12}
To correct the syntax issue, replace keep = msales{12} with keep = msales1-msales12

See the errors in log window :

153 data work.totalsales(keep = msales{12} ) ;

ERROR 214-322: Variable name { is not valid.


ERROR 23-7: Invalid value for the KEEP option.

Q10. The following SAS program is submitted:

data work.accounting;
set work.dept1 work.dept2;
run;

A character variable named JOBCODE exists in both the WORK.DEPT1 and


WORK.DEPT2 SAS data sets. The variable JOBCODE has a length of 5 in the
WORK.DEPT1 data set and a length of 7 in the WORK.DEPT2 data set.

Which one of the following is the length of the variable JOBCODE in the output data
set?

A. 5
B. 7
C. 8
D. 12

Answer : Since SAS checks the variable Job_code in DEPT1 for the first time of
length of 5 Bytes. it sets the length to be 5. All the values that are read from DEPT2
are truncated to Chars.
Q11. Which one of the following SAS statements renames two variables?
A. set work.dept1 work.dept2(rename = (jcode = jobcode) (sal = salary));
B. set work.dept1 work.dept2(rename = (jcode = jobcode sal = salary));
C. set work.dept1 work.dept2(rename = jcode = jobcode sal = salary);
D. set work.dept1 work.dept2(rename = (jcode jobcode) (sal salary));

Answer: B. The syntax for RENAME is as follows :


RENAME=(old-name-1=new-name-1 old-name-2=new-name-2. . . old-name-n=new-
name-n)

Q12. A raw data record is shown below:


07Jan2002

Which one of the following informats would read this value and store it as a SAS
date value?
A. date9.
B. ddmonyy9.
C. ddMMMyy9.
D. ddmmmyyyy9.

Answer : A

Q13. What does data _null_ mean?


data _null_ ;

This statement produces:

A. no SAS dataset
B. a SAS dataset named null
C. a SAS dataset named _null_
D. the largest possible dataset

Answer : A. The data _null_ does not produce a dataset.

It is used mainly for the following purposes :


1. To create macro variables with call symput
2. To create customized reports with PUT statements writing to external files.

Q14. The following SAS program is submitted:


data _null_;
set old (keep = prod sales1 sales2);
file 'file-specification';
put sales1 sales2;
run;

Which one of the following default delimiters separates the fields in the raw data file
created?
A. : (colon)
B. (space)
C. , (comma)
D. ; (semicolon)

Answer : B. Since no delimiter is specified at the end of the "file", the default
delimiter space will be used.

Q15. Which one of the following statements is true regarding the name of a SAS
array?

A. It is saved with the data set.


B. It can be used in procedures.
C. It exists only for the duration of the DATA step.
D. It can be the same as the name of a variable in the data set.

Answer : C.

Q16. The SASDATA.BANKS data set has five observations when the following SAS
program is submitted:

libname sasdata 'SAS-data-library';

data allobs;
set sasdata.banks;
capital=0;
do year = 2000 to 2020 by 5;
capital + ((capital+2000) * rate);
output;
end;
run;

How many observations will the ALLOBS data set contain?


A. 5
B. 15
C. 20
D. 25

Answer : D. Banks has 5 observations and then the do loop outputs for (20/5 + 1)
times. Therefore 5*(20/5 + 1) = 25 is the observation count .

Q17. The following SAS SORT procedure step generates an output data set:

proc sort data = sasuser.houses out = report;


by style;
run;

In which library is the output data set stored?

A.WORK
B.REPORT.
C.HOUSES
D.SASUSER

Answer : A. If library name is not specified then the data will be stored in temporary dataset
i.e. WORK.

Q18. The SAS data set named WORK.TEST is listed below:

Which one of the following SAS programs created this data set?

A.
data work.test;
capacity = 150;
if 100 le capacity le 200 then
airplanetype = 'Large' and staff = 10;
else airplanetype = 'Small' and staff = 5;
run;

B.
data work.test;
capacity = 150;
if 100 le capacity le 200 then
do;
airplanetype = 'Large';
staff = 10;
end;
else
do;
airplanetype = 'Small';
staff = 5;
end;
run;

C.
data work.test;
capacity = 150;
if 100 le capacity le 200 then
do;
airplanetype = 'Large';
staff = 10;
else
do;
airplanetype = 'Small';
staff = 5;
end;
run;

D.
data work.test;
capacity = 150;
if 100 le capacity le 200 then;
airplanetype = 'Small';
staff = 5;
else;
airplanetype = 'Large';
staff = 10;
run;

Answer : B. The problem with the options A,C and D is highlighted below in bold.

A. data work.test;
capacity = 150;
if 100 le capacity le 200 then
airplanetype = 'Large' and staff = 10;
else airplanetype = 'Small' and staff = 5;
run;

Log : NOTE: Variable staff is uninitialized.


C. data work.test;
capacity = 150;
if 100 le capacity le 200 then
do;
airplanetype = 'Large';
staff = 10;
else /*end missing for if do loop*/
do;
airplanetype = 'Small';
staff = 5;
end;
run;

Log : ERROR 117-185: There was 1 unclosed DO block.

NOTE: The SAS System stopped processing this step because of errors.

D. data work.test;
capacity = 150;
if 100 le capacity le 200 then;
airplanetype = 'Small';
staff = 5;
else; /* there is no if associated with this else */
airplanetype = 'Large';
staff = 10;
run;

Log : ERROR 160-185: No matching IF-THEN clause

Q19. The following SAS program is submitted:

data work.flights;
destination = 'CPH';
select(destination);
when('LHR') city = 'London';
when('CPH') city = 'Copenhagen';
otherwise;
end;
run;
Which one of the following is the value of the CITY variable?
A. London
B. Copenh
C. Copenhagen
D. ' ' (missing character value)

Answer : B.

Notice that the LENGTH statement in the SELECT group has not been specified.
Remember that without the LENGTH statement, values for Group might be
truncated, as the first value for Group (London) is not the longest possible value.

city = 'London' - It contains 6 characters.


'Copenhagen' will be truncated to 6 characters i..e Copenh.

Q20. A raw data file is listed below:


--------10-------20-------30
John McCloskey 35 71
June Rosesette 10 43
Tineke Jones 9 37

The following SAS program is submitted using the raw data file as input:
data work.homework;
infile 'file-specification';
input name $ age height;
if age LE 10;
run;

How many observations will the WORK.HOMEWORK data set contain?


A. 0
B. 2
C. 3
D. No data set is created as the program fails to execute due to errors.

Answer : C. The data set homework will have missing values under the age variable.
The name has a blank in it so we need to use the & list modifier to read the data,
also when using this we have to make sure that the data are at least two spaces
apart.

As SAS considers missing values smaller than 10 in age variable so it has included
all the three observation in the data set.

The corrected code is as follows:

Data
homewo;

input fname$ lname $ age


height;
if age LE
10;
datalines;

John McCloskey 35
71
June Rosesette 10
43
Tineke Jones 9 37
;
run
Q21. The following SAS program is submitted:

data work.one;
x = 3;
y = 2;
z = x ** y;
run;

Which one of the following is the value of the variable Z in the output data set?
A. 6
B. 9
C. . (missing numeric value)
D. The program fails to execute due to errors.

Answer: B.

** = exponentiation
X**Y raise X to the power of Y
So 3 to the power of 2 = 9

Q22. The following SAS program is submitted:

data work.new;
length word $7;
amount = 7;
if amount = 5 then word = 'CAT';
else if amount = 7 then word = 'DOG';
else word = 'NONE!!!';
amount = 5;
run;
Which one of the following represents the values of the AMOUNT and WORD
variables?

A. amount word
5 DOG

B. amount word
5 CAT

C. amount word
7 DOG

D. amount word
7 ' ' (missing character value)

Answer : A. When SAS reads in the iterations in sequence, it first writes 7 to the
variable 'amount' in PDV. Then it reads through the condition and writes 'DOG' for
variable 'word' in PDV. Then it again encounters the value 5 and writes to 'Amount' in
PDV.

Q23. The following SAS program is submitted:


data _null_;
set old;
put sales1 sales2;
run;
Where is the output written?

A. the SAS log


B. the raw data file that was opened last
C. the SAS output window or an output file
D. the data set mentioned in the DATA statement

Answer : A.

Q24. The following SAS program is submitted:

data work.report;
set work.sales_info;
if qtr(sales_date) ge 3;
run;

The SAS data set WORK.SALES_INFO has one observation for each month in the
year 2000 and the variable SALES_DATE which contains a SAS date value for each
of the twelve months.
How many of the original twelve observations in WORK.SALES_INFO are written to
the WORK.REPORT data set?

Answer : C. The qtr (quarter) values of each of the months (July through December)
7,8,9,10,11,12 is 3,3,3,4,4,4..Therefore 6 obs are included in the final dataset.

Q25. The following SAS DATA step is submitted:

data sasdata.atlanta sasdata.boston work.portland work.phoenix;


set company.prdsales;
if region = 'NE' then output boston;
if region = 'SE' then output atlanta;
if region = 'SW' then output phoenix;
if region = 'NW' then output portland;
run;

Which one of the following is true regarding the output data sets?
A. No library references are required.
B. The data sets listed on all the IF statements require a library reference.
C. The data sets listed in the last two IF statements require a library reference.
D. The data sets listed in the first two IF statements require a library reference.

Answer : D. The datasets in the first two IF statements require "sasdata" libref.

Q26. The following SAS program is submitted:

proc sort data=work.employee;


by descending fname;

proc sort data=work.salary;


by descending fname;

data work.empdata;
merge work.employee work.salary;
by fname;
run;

Which one of the following statements explains why the program failed execution?

A. The SORT procedures contain invalid syntax.


B. The merged data sets are not permanent SAS data sets.
C. The data sets were not merged in the order by which they were sorted.
D. The RUN statements were omitted after each of the SORT procedures.

Answer : C. The two proc sorts are arranged in descending order. However, the
merge is in ascending order. Hence, the two data sets won't be merged.

In merge if you choose to sort by descending then you must use descending with
merge statement otherwise it will not merge because of reason ( C ). It does not
matter if you sort by ascending order.

Q27. Which one of the following is true of the SUM statement in a SAS DATA step
program?

A. It is only valid in conjunction with a SUM function.


B. It is not valid with the SET, MERGE and UPDATE statements.
C. It adds the value of an expression to an accumulator variable and ignores missing values.
D. It does not retain the accumulator variable value from one iteration of the SAS DATA step
to the next.

Answer : C.

Q28. The SAS data sets WORK.EMPLOYEE and WORK.SALARY are listed below:

WORK.EMPLOYEE
fname age
Bruce 30
Dan 40
Dan 25000

WORK.SALARY
fname salary
Bruce 25000
Bruce 35000

The following SAS program is submitted:

data work.empdata;
merge work.employee work.salary;
by fname;
totsal + salary;
run;
How many variables are output to the WORK.EMPDATA data set?
A. 3
B. 4
C. 5
D. No variables are output to the data set as the program fails to execute due to errors.

Answer : B. The variables are: Fname, age, salary and totsal.


Note: Obs will not be counted here.

Q29. The following SAS program is submitted:


data work.sets;
do until (prod gt 6);
prod + 1;
end;
run;

Which one of the following is the value of the variable PROD in the output data set?
A. 5
B. 6
C. 7
D. 8

Answer : C. Because of prod + 1 statement, SAS compiler will assume a retain prod
0; statement.

First loop => prod = 1 => (1 gt 6) => false, loop continues


Second loop => prod = 2 => (2 gt 6) => false, loop continues
.....
last loop => prod = 7 => (7 gt 6) => true, do until loop exits and pdv writes prod value
of 7 to output dataset.

Q30. Which of the following is not an error identified during the compilation phase?

A) Quotation marks are unbalances


B) No RUN statement in the step
C) An option is invalid
D) Semicolons are missing in statements

Answer : B.

Q31. The following SAS program is submitted:


libname rawdata1 'location of SAS data library';
filename rawdata2 'location of raw data file';
data work.testdata;
infile
input sales1 sales2;
run;

Which one of the following is needed to complete the program correctly?


A. rawdata1
B. rawdata2
C. 'rawdata1'
D. 'rawdata2'

Answer: B. Since we have already initialized the path with a filename, we do not
have to include quotation again.

Q32. The following SAS program is submitted and reads 100 records from a raw data
file:
data work.total;
infile 'file-specification' end = eof;
input name $ salary;
totsal + salary;

run;
Which one of the following IF statements writes the last observation to the output
data set?
A. if end = 0;
B. if eof = 0;
C. if end = 1;
D. if eof = 1;

Answer : D. End is a sas keyword which will become true when SAS reads last
record of a dataset. This value you cannot use directly in your program, so we create
a alias name eof (end of file), but you can name it anything. EOF will carry the same
value as internal variable END. So as we know 1=true and 0= false. if EOF = 1; will
output only the last observation.

Q33. In the following SAS program, the input data files are sorted by the NAMES
variable:

libname temp 'SAS-data-library';


data temp.sales;
merge temp.sales work.receipt;
by names;
run;

Which one of the following results occurs when this program is submitted?
A. The program executes successfully and a temporary SAS data set is created.
B. The program executes successfully and a permanent SAS data set is created.
C. The program fails execution because the same SAS data set is referenced for
both read and write operations.
D. The program fails execution because the SAS data sets on the MERGE
statement are in two different libraries.

Answer : B. temp is declared as a permanent library so permanent dataset will be


created.

Q34. The contents of two SAS data sets named EMPLOYEE and SALARY are listed
below:

data emplsal;
merge employee (in=ine) salary(in=ins);
by name;
if ine and ins;
run;

How many observation are in EMPLSAL dataset?


A. 4
B. 3
c. 2
D. 1

Answer : A.

Run the following SAS code and see what you got in the EMPSAL dataset:

data salary;
input name $ salary;
datalines;
Bruce 40000
Bruce 35000
Dan 37000
Dan .
;
run;

data employee;
input name $ age;
datalines;
Bruce 30
Dan 35
;
run;

data emplsal;
merge employee (in=ine) salary(in=ins);
by name;
if ine and ins;
run;

Q35. The following SAS program is submitted:


data work.products;
Product_Number = 5461;
Item = '1001';
Item_Reference = Item'/'Product_Number;
run;
Which one of the following is the value of the variable ITEM_REFERENCE in the
output data set?
A. 1001/5461
B. 1001/ 5461
C. . (missing numeric value)
D. The value can not be determined as the program fails to execute due to errors.

Answer : D. Since there is no concatenate symbol between Item and


Product_Number.

Q36. The following SAS program is submitted:

libname sasdata 'SAS-data-library';


data test;
set sasdata.chemists (keep = job_code);
if job_code = 'chem3'
then description = 'Senior Chemist';
run;

The variable JOB_CODE is a character variable with a length of 6 bytes.

Which one of the following is the length of the variable DESCRIPTION in the output
data set?
A. 6 bytes
B. 8 bytes
C. 14 bytes
D. 200 bytes

Answer : C. The length of 'Senior Chemist' is 14.

Q37. Which one of the following is true of the RETAIN statement in a SAS DATA step
program?

A. It can be used to assign an initial value to _N_ .


B. It is only valid in conjunction with a SUM function.
C. It has no effect on variables read with the SET, MERGE and UPDATE statements.
D. It adds the value of an expression to an accumulator variable and ignores missing values.

Answer : C.

The RETAIN statement


- is a compile-time only statement that creates variables if they do not already exist
- initializes the retained variable to missing before the first execution of the DATA step if you
do not supply an initial value
- has no effect on variables that are read with SET, MERGE, or UPDATE statements.

Q38. The following SAS program is submitted:

data work.test;
Title = 'A Tale of Two Cities, Charles J. Dickens';
Word = scan(title,3,',');
run;

Which one of the following is the value of the variable WORD in the output data set?
A. T
B. of
C. Dickens
D. ' ' (missing character value)

Answer : D.

Q39. Which one of the following is true when SAS encounters a data error in a DATA
step?

A. The DATA step stops executing at the point of the error, and no SAS data set is
created.
B. A note is written to the SAS log explaining the error, and the DATA step continues
to execute.
C. A note appears in the SAS log that the incorrect data record was saved to a
separate SAS file for further examination.
D. The DATA step stops executing at the point of the error, and the resulting DATA
set contains observations up to that point.

Answer : B. If it's a syntax error then the A occurs.


If it's an error with invalid data then B will occur .
If it's a problem with merging two or more datasets, then D will occur.

Q40. The SAS data set EMPLOYEE_INFO is listed below:

IDNumber Expenses
2542 100.00
3612 133.15
2198 234.34
2198 111.12

The following SAS program is submitted:


proc sort data = employee_info;

run;

Which one of the following BY statements completes the program and sorts the data
sequentially by ascending expense values within each ascending IDNUMBER
value?

A. by Expenses IDNumber;
B. by IDNumber Expenses;
C. by ascending (IDNumber Expenses);
D. by ascending IDNumber ascending Expenses;
Answer : B. By default SAS will sort data in ascending order. IDNumber should be
specified before Expenses as we want IDNUMBER to be sorted in ascending.

You might also like