Sie sind auf Seite 1von 32

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)
Click Comment link to get answer

The contents of the raw data file AMOUNT are listed below:
--------10-------20-------30
$1,234
The following SAS program is submitted:
data test;
infile 'amount';
input @1 salary 6.;
if _error_ then description = 'Problems';
else description = 'No Problems';
run;
Which one of the following is the value of the DESCRIPTION variable?
A. Problems
B. No Problems
C. ' ' (missing character value)
D. The value can not be determined as the program fails to execute due to errors.
The Answer will be A. as the program has an error which is compilation error so this will falg
_ERROR_ to 1.

SAS Certification- Diagnostic test


1. The following is an example of.... (Choose one)

data employee;
infile 'employee.dat'; /* Assuming directory-based system */
input id $6. name $20. @30 locale $10.;
run;
A. List
B. Column
C. Formatted
D. Mixed
E. Standard
2. True or False...(Choose one)
The extesion of ".sas" is required for sas program files.
A. True
B. False
3. Which of the following are valid statements concerning reading raw data files using list input:
(Choose all
that apply)
A. The DLM= is an option for the infile statement for specifying delimiters.
B. All variables have a default length of 8 bytes.
C. When the input statement runs into an end-of-line marker, it stops reading data even
though there are more fields specified.
D. You use a $ after a variable name to specify a character variable.
E. Fields are read from left to right.
4. Given the following raw data file, offices.dat, in a directory-based system, which data step
would create a
SAS data set with one observation for each region: (Choose One)
1122334
1234567890123456789012345678901234567890
East Maryland Vermont Maine
Central Illinois Iowa Kansas Missouri
West California Washington
A.
data offices;
infile 'offices.dat' stopover;
input region $ state1-state4 $;
run;
B.
data offices;
infile 'offices.dat' missover;
input region $ (state1-state4) ($);
run;
C.
data offices;
infile 'offices.dat' delim=" ";
input region $ state1 $ state2 $ state3 $ state4 $;
run;

D.
data offices;
infile 'offices.dat';
input region $ state1-state4 $.;
run;
E. None of the above.
5. The double trailing "@@" in an input statement...(Choose all that apply)
A. holds the current data line in the buffer for another input statement to process
B. can be used to read multiple observations from a single data line
C. loads a new record into the input buffer if an end-of-record is found in the current record
D. is a syntax error.
E. None of the above.
6. Which SAS statement below wil change the characteristics of a variable if it was used in a
data step?
A. SCAN
B. ATTRIB
C. FORMAT
D. PUT
E. ARRAY
7. Which X variable has a value of 1 at the end of an input file?
A. END = X
B. OBS = X
C. EOF = X
D. LASTOBS = X
E. NOOBS = X
8. Given a data file with 100 columns of data, you only need to read in the first 70 colums.
Which of the
following could you use:
A. infile x line = 70;
B. infile x length = 71;
C. infile x missover = 70;
D. infile x ls=70;
E. infile x linesize=70;
9. In the following code sample:
data xyz;
infile abc;
input h i +3 j;
run;
What does the +3 do?
A. It moves the pointer down 3 records
B. It moves the column pointer to column 3
C. It adds 3 to the value read into variable i
D. It advances the column pointer 3 places
E. It advances the column pointer 4 places

10. What does the following SAS statement do?


if location =: 'C';
A. It selects the observation if there is a 'C' in the location value.
B. It selects the observation if there is a 'C' at the first position in the location value.
C. It selects the observation if the location value is 'C'.
D. It selects the observation if the location value contains a lowercase 'c'.
E. None of the above, it's a typo.
The following program is submitted.
data test;
input name $ age;
cards;
John +35
;run;
11. Which values are stored in the output data set?
A. name age
John 35
B. name age
John (missing value)
C. name age
(missing value) (missing value)
D. The DATA step fails execution due to data errors.
12.The following observation is stored in a SAS data set named EMPLOYEES:
LNAME FNAME JOBCODE
---------------------------------------------------------------------Whitley Sam na1
If the DATA step below is executed, what will be the value of the variable JOBDESC in the
output SAS data
set when this observation is processed:
data navigate;
set employees;
if jobcode = 'NA1' then jobdesc = 'Navigator';
run;
A. navigator
B. Navigator
C. NAVIGATOR
D. a missing value
13.The following SAS program is submitted:
proc format;
value score 1 - 50 = 'Fail'
51 - 100 = 'Pass';
run;
Which one of the following PRINT procedure steps correctly applies the format?

A. proc print data = sasuser.class;


B. var test;
C. format test score;
D. run;
E. proc print data = sasuser.class;
F. var test;
G. format test score.;
H. run;
I. proc print data = sasuser.class format = score;
J. var test;
K. run;
L. proc print data = sasuser.class format = score.;
M. var test;
N. run;
14 Given the following DATA step:
data loop;
x = 0;
do index = 1 to 5 by 2;
x = index ;
end;
run;
Upon completion of execution, what are the values of the variables X and INDEX in the SAS
data set named
LOOP?
A. x = 3, index = 3
B. x = 3, index = 4
C. x = 5, index = 5
D. x = 5, index = 6
E. x = 5, index = 7
15 Given that the data set named ONE contains 10 observations and the data set named TWO
contains 10
observations, how many observations will be contained in the data set named COMBINE that is
created in
the following DATA step?
data combine;
set one two;
run;
A. 10
B. 20
C. 0, the DATA step will fail due to syntax errors
D. 10 to 20, depending on how many observations match

GO TOP

SAS Practice Test II

1. A format statement should be specified before the CARDS statement when we read internal
raw data.
a. True
b. False
2. An external file with a maximum record length of 225 is read into SAS in a DATA step. Select
all statements that reads the data correctly.
a. INFILE C:\mydata.dat LRECL=2000;
b. INFILE C:\mydata.dat LRECL=225;
c. INFILE C:\mydata.dat ;
3. Select the False statement about List Input method of reading data
a. Reads data separated by several spaces.
b. Does not skip over unwanted values in the input data.
c. Reads a date.
4. Column Input style can read a character data value with space embedding
a. True
b. False
5. A standard numeric data in SAS can contain a - (negative) sign and E for scientific notations
a. True
b. False
6. A non standard data (Numbers with comma, dates like 03-OCT-2005 ) can be read with the
following INPUT styles (select all correct answers)
a. Formatted Input
b. Modified List Input
c. Using Informats in INPUT statement
7. Given the line of raw data:
112233 SCODES Z M N
And the data statement:
INPUT @'SCODES' statuscodes :$10.;
When executed in a DATA step correctly, what value the variable Statuscodes gets?

a. Z
b. Z M N
c. . (Missing)

8. The following statement is submitted:


Data Test;
INPUT accnum $ / fname $ lname $ ;
cards;
12223242 Johny Smith
Peter Smith Thomas Joseph
;run;
The output dataset will show which of the following?
a. accnum fname lname
12223242 Johny Smith
b. accnum fname lname
12223242 Peter Smith
c. None of the above
9. The following statement is submitted:
Data Test;
INPUT accnum $ #2 fname $ lname $ ;
cards;
12223242 Johny Smith
Peter Smith Thomas Joseph
;run;
The output dataset will show which of the following?
a. accnum fname lname
12223242 Johny Smith
b. accnum fname lname
12223242 Peter Smith
c. None of the above
10. The following INPUT statements are submitted:
Data Test;
INPUT accnum $ fname $ lname $ @@ ;
cards;
122232 Johny Smith 132343 Peter Smith 142434 Thomas Joseph;
run;
Which of the following statement is correct?

a. Output record set will have only one record


b. Output record set will have 3 records
c. Data step incomplete due to incorrect syntax

11. Datafile c:\mydata.dat contains account number, first name and last name of account
holders with following structure.
122232 Johny Smith
142434 Thomas
152535 Dan Paul
Which statement below reads the data correctly into SAS.
a. Data Test;
INFILE 'c:\mydata.dat' MISSOVER;
INPUT accnum $ 1-6 fname $ 8-14 lname $ 16-20;
run;
b. Data Test;
INFILE 'c:\mydata.dat' TRUNCOVER;
INPUT accnum $ 1-6 fname $ 8-14 lname $ 16-20;
run;
c. Data Test;
INFILE 'c:\mydata.dat' ;
INPUT accnum $ fname $ lname $;
run;
12. The following statement is submitted
Data Test;
INFILE 'c:\mydata.dat;
INPUT client_id $ 1-3 @;
IF client_id 'JCP' then delete;
INPUT accnum $ 4-8 fname $ 9-14 lname $ 16-20;
run;
How many columns will be there in dataset Test ?
a. None
b. 3
c. 4
13. An external data file has account open date in the following format .

01-13-95
01-14-96
01-15-97
Which of the following is a correct INPUT statement in DATA step to read this data.
a. INPUT Account_no mmddyy8. ;
b. INPUT Account_no mmddyy6. ;
c. INPUT Account_no ddmmyy8. ;
14. The following statements are submitted
Data Test;
today = '20dec2005'd;
format today mmddyy10.;
run;
Which of the following statement is true ?
a. Today variable displays like 12/20/2005
b. Data step not executed due to wrong format mmddyy.
c. Today is displayed as 20DEC2005
15. Following statements are submitted:
proc export data = Account_perf outfile = 'd:\text1.csv';
run;
proc export data = Account_perf outfile = 'd:\text2.csv'
DBMS =DLM REPLACE;
DELIMITER =',';
run;
Select all false statements:
a. There are two files , text1.csv and text2.csv , created in d:\
b. Both text1 and text2 files have the same data values delimited by a comma
c. Text1 data file will have a space-delimited data as a standard SAS output.
d. Only text2.csv is created with values delimited by a comma.
GO TOP
SAS Practice Test III

Note: the programs in the example e expects no errors due to improper use of ;, , ) etc.

1. File C:\mydata.dat contains 100 complete records and the following program is submitted.
options obs=10;
Data Test;
INFILE 'c:\mydata.dat' firstobs=3;
INPUT accnum $ fname $ lname $;
run;
Which of the following statement is correct?
a. Test data set will have 98 rows
b. Test dataset will have first 10 observations
c. Test dataset will have 10 observations read starting from third data line in mydata.dat
d. Test dataset will have 8 observations read starting from third data line in mydata.dat
2. The following program is submitted to read a delimited file
Data Test;
INFILE 'c:\mydata.dat' DLM='$' DSD ;
INPUT accnum $ fname $ lname $;
run;
What DSD keyword does here? (Select all correct answers)
a. It does not treat $ character as part of the data value and treat it as delimiter.
b. It recognize two consecutive $ characters as a missing value for the variable read
c. If data value is specified in quotes with embedded $ character DSD option treats it as part of
the data.
3. A PROC DATATSETS is used as follows(assumption: all libraries are and datasets are
existing):
proc datasets library=mylib details;
copy out=rloc;
select scoredata;
delete tension ;
run;
Which statement below explains the operations above most correctly?
a. It lists all SAS data files with file size and date modified in mylib library and makes a copy of
scoredata file in rloc library and deletes tension dataset..
b. It lists all SAS data files with file size and date modified in mylib library and deletes tension
file from rloc library.
c. It lists all SAS data files with file size and date modified in mylib library and makes a copy of
scoredata file in rloc library and also copies the scoredata file in rloc library.
d. It lists all sas data files with file size and date modified in mylib library and makes a copy of
scoredata file in rloc library.
4. The following program is submitted. Which is a false statement about the output of this
program?

proc contents data=scoredata;


run;
a. Prints # of observations in scoredata
b. Prints a snapshot of the data into the screen.
c. Prints the date scoredata was created
d. Lists all labels associated with variables in scoredata

5. The following line of code is used in a SAS data step .


Data xx;
Set yy;
attrib status_codes length=$4 label ='Status Codes' format =$upcase8.;
run;
If yy has a variable names status_codes and the user wants the attributes to be changed in xx .
Will this statement change the length, label and format in xx dataset?
a. YES
b. NO
c. No Sufficient Information

6. The below three program blocks are submitted


A) Data target_data ;
Set base_data((keep = var1 var2 var3 );
Run;
B) Data target_data ;
Set base_data;
keep = var1 var2 var3 ;
Run;
C) Data target_data (keep = var1 var2 var3 );
Set base_data;
Run;
If the user needs only var1, var2 and var3 to work with, which step is most efficient?
a. A
b. B
c. C
d. A&B
e. None

7. The following program is submitted (Assumption is os_dollars is an existing dataset with


client groups (client_group) and dollar outstanding (os) fields. ) .
Data test;
SET os_dollars END=FIN ;
BY client_group;
t_os +os;
IF LAST.clinet_group THEN DO ;
g_os +t_os ;
t_os=0;END;run;
What this program does?
a. Computes the gross outstanding across the groups and store it in g_os variable, last row.
b. Computes the oustandings for client groups and retain them in t_os variable
c. None of the above.

8. The following program was submitted to SAS


data temp;
length my_number $ 4;
input my_number;
cards;
1234
0009
;run;
data new(drop=x);
set temp(rename=(my_number=x));
my_number=input(x,best4.);run;
proc print data=new;run;
Whats the output would be?
A) Obs my_number
1 1234
2 9
B) Obs my_number
1 1234
2 0009
C) Obs my_number
.
.
9. The following program is submitted:

x='20jan94'd;
y=qtr(x);
put y=;
What value would be printed to the SAS log?
a. 1
b. 2
c. 3
d. None
10. The following program submitted:
data xx;
date1=122591;
date2=put(date1,z6.);run;
Whats the data type of date1 and date 2 ?
a. Date1 Character, Date 2 Numeric
b. Date1 numeric, Date 2 character
c. Syntax error, not executed

11. The following statement forms a part of SAS dataset (no syntax errors)
Data xx;
Set yy;
array weight wt1-wt50;
do i=1 to 50;
if weight{i}=999 then weight{i}=missing;
end;
run;
Select all correct statements below:
a. Creates a variable weight and assigns w1-wt50 (wt1, wt2, wt3 etc)
b. Variables named wt1-wt50 exist in the yy data set.
c. If any of the fields in wt1-wt50 have a value of 999 then it will be reset with a missing .
d. Evaluated all 50 fields and the entire table looking for value 999 in any of the fields

12. The following program is submitted:


proc report data =xx nowindows headline headskip ;
Title 'Summary across groups;
column s_g N (os co), MEAN ;

define s_g /group;


run;
Whats the objective of using MEAN?
a. Compute mean (Average) of variables OS and CO
b. Compute mean and N(count) of s_g and MEAN of OS and CO
c. Compute mean and N(count) of s_g and MEAN of OS and CO by s_g groups.
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 error :
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.

Das könnte Ihnen auch gefallen