Base SAS Certification Questions and Answers Part – 4

Real Time Base SAS Certification Questions and Online Practice Exams

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

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

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

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

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;

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

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

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

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

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

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

Real Time Base SAS Certification Questions and Online Practice Exams