Академический Документы
Профессиональный Документы
Культура Документы
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?
SET temp;
KEEP v1 v2 v3
RUN;
RUN;
RUN;
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.
DATA one;
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
4, 5, 6,
7, 8, 9,
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.
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
a) log
b) logical
c) varnum
d) var
C
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.
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
The keyword "data" is misspelled above. What happens to this program during the compilation
phase assuming "corn" is a valid libref?
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!
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
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
a) last paid_by
b) paid_by.last
c) paid_by.last = 1
d) last.paid_by = 1
D
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.
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
a) _NUMERIC_
b) _CHARACTER_
c) _ALL_
d) None of the above
Ans is D
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?
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;
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
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.
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
Solution: (C)
Look at the syntax of PROC FREQ, there is not SET statement required.
BY variables ;
TEST options ;
RUN;
Q3) We have submitted the following PROC SORT step, which generates an
output data set.
by Designation;
run;
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;
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;
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;
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.
Set Salary;
run;
B.
Set Salary;
run;
C.
Set Salary;
run;
Solution: (B)
data AV;
do year=2000 to 2004;
Capital+5000;
capital+(capital*.10);
output;
end;
run;
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?
Solution: (D)
SET can not be used to read raw data files. SET is used to read data from one or
more SAS dataset.
Employee id,Gender,Name,DOB,Location,Salary,ManagerEmp ID
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
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.
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;
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
C. Both A and B
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
run;
A. 1
B. 2
C. 3
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;
Solution: (A)
Q17) If you submit the following program on above data set, which variables
appear in table Emp?
Age = yrdif(DOB,'05Feb2017'd,'Actual'd);
run;
C. Employee_ID
D. Employee_ID, Age
E. Employee_ID, Age, DOB
Solution: (D)
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;
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
A.
run;
B.
run;
C.
run;
D. Both B and C
Solution: (B)
Options with PROC MEANS:
Q20) Which of the following command will help to impute the missing value of
column Hindi with average marks of Hindi?
A)
Proc SQL;
quit;
Set temp;
Else Hindi_2=Hindi;
run;
B)
Proc SQL;
quit;
Set class;
Else Hindi_2=Hindi;
run;
C) Both A and B
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
Delhi_NC
C406 17-Jan-17 8 5
R
Delhi_NC
C203 20-Jan-17 7 1
R
Table-2
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.
run;
B.
data work.merge_table;
run;
PROC SORT DATA = merge_table OUT = merge_table NODUPKEY;
by Product_ID;
run;
C.
data work.merge_table;
run;
by Product_ID ;
run;
Solution: (B)
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)
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?
if Proposed_Booking_Date;
run;
A.
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.
Solution: (C)
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;
run;
B.
data t2;
set TABLE2;
C.
data t2;
set TABLE2;
run;
D. Both B and C
E. Both A and B
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.
A. @n
B. +N
C. /
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
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.
tables Education;
run;
B.
var Education;
run;
C. Both A and B
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.
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;
run;
B.
data Table5;
set Table5;
Salutation = scan(name, -1);
run;
C.
data Table5;
set Table5;
run;
data test2;
set Table5;
run;
data test2;
set Table5;
Solution: (A)
SCAN(string, count_words)
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
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;
run;
B.
data AV;
Set table5;
run;
C. Both A and B
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.
tables Education*Loan_Status;
run;
B.
C.
run;
D.
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
charge=LoanAmount *0.4;
run;
Program2
data AV;
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
44 data WORK.OUTPUT;
45 set SASHELP.CLASS;
46 BMI=(Weight*703)/Height**2;
48 run;
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;
do i = 1 to 3;
Period = cat('Qtr',i);
Amount = Qtr{i};
output;
end;
drop Q1 Q2 Q3 i;
if Amount ne .;
run;
B.
by cust;
run;
C. Both A and B
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)
A. PROC SGPLOT
B. PROC UNIVARIATE
C. PROC PLOT
Solution: (A)
Question Context 37 38
Table6
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
Q37) Which of the following command can be used to plot below chart?
A.
B.
by Month;
run;
C.
Line Month;
run;
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.
run;
B.
C.
run;
D.
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.
run;
by ID Area_Type;
run;
B.
run;
by ID Area_Type;
run;
C.
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);
otherwise Volume_Bucket="C";
end;
run;
B.
Data table7;
set table7;
Else Volume_Bucket="C";
run;
C. Both A and 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.
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.
Answer: C. For every BY group we get the sum of wagerate in the Payroll variable
for each department.
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)
Q3. The contents of the raw data file NAMENUM are listed below:
--------10-------20-------30
Joe xx
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?
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?
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...
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. 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
data work.accounting;
set work.dept1 work.dept2;
run;
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));
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
A. no SAS dataset
B. a SAS dataset named null
C. a SAS dataset named _null_
D. the largest possible dataset
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?
Answer : C.
Q16. The SASDATA.BANKS data set has five observations when the following SAS
program is submitted:
data allobs;
set sasdata.banks;
capital=0;
do year = 2000 to 2020 by 5;
capital + ((capital+2000) * rate);
output;
end;
run;
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:
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.
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;
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;
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.
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;
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.
Data
homewo;
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
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.
Answer : A.
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.
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.
data work.empdata;
merge work.employee work.salary;
by fname;
run;
Which one of the following statements explains why the program failed execution?
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?
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
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.
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.
Q30. Which of the following is not an error identified during the compilation phase?
Answer : B.
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:
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.
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;
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;
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
Q37. Which one of the following is true of the RETAIN statement in a SAS DATA step
program?
Answer : C.
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.
IDNumber Expenses
2542 100.00
3612 133.15
2198 234.34
2198 111.12
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.