0% found this document useful (0 votes)
38 views23 pages

Practice Questions 3

Sas paper project
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views23 pages

Practice Questions 3

Sas paper project
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 23

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.

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)

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.
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

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
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

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

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

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.
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

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));
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.

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

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)

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.

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

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

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;

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)

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.

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.

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)

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

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?

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.

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.
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.

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.

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

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
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'

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;
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.

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

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.

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

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.

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)

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

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;

You might also like