SAS PROGRAMMING CERTIFICATION
TEST QUESTIONS WITH COMPLETE
SOLUTIONS
3.3 When you specify an engine for a library, what are you 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 - Answer- 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' file
3.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; - Answer- 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
3.5 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;
set mydata.quarter1sales;
if sales>100000;
run;
b. data mysales.totals;
set sales_2017.salesanalysis;
if totalsales>50000;
run;
c. proc print data=salesanalysis.quarter1;
var sales salesrep month;
run;
d. proc freq data=2017data.salesanalysis;
tables quarter*sales;
run; - Answer- Correct answer: b
Librefs must be 1 to 8 characters long, must begin with a letter or underscore, and can
contain only numbers, letters, or underscores. After you assign a libref, you specify it as
the first level in the two-level name for a SAS file
,3.6 What type of information does the CONTENTS procedure create?
a. the contents of a library
b. descriptor information for an individual SAS data set
c. both A and B
d. none of the above - Answer- Correct answer: c
The CONTENTS procedure creates a report that contains the contents of a library or
the descriptor information for an individual SAS data set.
3.7 Assuming you are using SAS code, 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. - Answer- Correct answer: c
The LIBNAME statement is global, which means that librefs stay in effect until changed
or canceled, or until the SAS session ends
3.8 What does the following statement do?
Lib name states 'c:\my files\sasdata\popstats';
a. defines a library called States using the Popstats engine
b. defines a library called Popstats using the States engine
c. defines the default library using the default engines
d. defines a library called States using the default engine - Answer- Correct answer: d
The LIBNAME statement does not specify an engine. Therefore, it uses a default engine
to create the States library
4.1 Which SAS statement associates the fileref Crime with the raw data file C:\States \
Data\crime.dat?
a. filename crime 'c:\states\data\crime.dat';
b. filename crime c:\states\data\crime.dat;
c. fileref crime 'c:\states\data\crime.dat';
d. filename 'c:\states\data\crime' crime.dat; - Answer- Correct answer: a
You assign a fileref by using a FILENAME statement in the same way that you assign a
libref by using a LIBNAME statement
4.2 Which type of delimited file does PROC IMPORT read by default?
a. logical record-length files
b. varying record-length files
c. fixed record-length files
d. illogical record-length files - Answer- Correct answer: b
By default, the IMPORT procedure reads delimited files as varying record-length files
, 4.3 Which program correctly imports only the first seven observations from the external
file?
a. options obs=7;
proc import data="C:\users\test.txt"
out=exam
dbms=dlm
replace;
run;
proc print data=exam;
run;
b. proc import datafile="c:\users\test.txt"
out=exam
dbms=dlm
replace;
options obs=7;
run;
proc print data=exam;
run;
c. proc import datafile="c:\users\test.txt"
out=exam
dbms=dlm
replace;
run;
proc print data=exam (obs=7);
run;
d. proc import datafile="c:\users\test.txt"
out=exam
dbms=dlm
replace;
run;
proc print data=exam;
options obs=7;
run; - Answer- Correct answer: a
Use the OBS= option in the OPTIONS statement before the IMPORT procedure to limit
the number of observations that SAS reads from the external file
4.4 Which of the following pieces of information does SAS need in the DATA step in
order to read an Excel workbook file?
a. a libref to reference the Excel workbook to be read
b. the name and location (using another libref) of the new SAS data set
c. the name of the Excel worksheet that is to be read
d. all of the above - Answer- Correct answer: d
To read an Excel workbook file, SAS must receive the following information in the DATA
step: a libref to reference the Excel workbook to be read, the name and
Chapter location (using another libref) of the new SAS data set, and the name of the
Excel worksheet that is to be read
TEST QUESTIONS WITH COMPLETE
SOLUTIONS
3.3 When you specify an engine for a library, what are you 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 - Answer- 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' file
3.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; - Answer- 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
3.5 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;
set mydata.quarter1sales;
if sales>100000;
run;
b. data mysales.totals;
set sales_2017.salesanalysis;
if totalsales>50000;
run;
c. proc print data=salesanalysis.quarter1;
var sales salesrep month;
run;
d. proc freq data=2017data.salesanalysis;
tables quarter*sales;
run; - Answer- Correct answer: b
Librefs must be 1 to 8 characters long, must begin with a letter or underscore, and can
contain only numbers, letters, or underscores. After you assign a libref, you specify it as
the first level in the two-level name for a SAS file
,3.6 What type of information does the CONTENTS procedure create?
a. the contents of a library
b. descriptor information for an individual SAS data set
c. both A and B
d. none of the above - Answer- Correct answer: c
The CONTENTS procedure creates a report that contains the contents of a library or
the descriptor information for an individual SAS data set.
3.7 Assuming you are using SAS code, 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. - Answer- Correct answer: c
The LIBNAME statement is global, which means that librefs stay in effect until changed
or canceled, or until the SAS session ends
3.8 What does the following statement do?
Lib name states 'c:\my files\sasdata\popstats';
a. defines a library called States using the Popstats engine
b. defines a library called Popstats using the States engine
c. defines the default library using the default engines
d. defines a library called States using the default engine - Answer- Correct answer: d
The LIBNAME statement does not specify an engine. Therefore, it uses a default engine
to create the States library
4.1 Which SAS statement associates the fileref Crime with the raw data file C:\States \
Data\crime.dat?
a. filename crime 'c:\states\data\crime.dat';
b. filename crime c:\states\data\crime.dat;
c. fileref crime 'c:\states\data\crime.dat';
d. filename 'c:\states\data\crime' crime.dat; - Answer- Correct answer: a
You assign a fileref by using a FILENAME statement in the same way that you assign a
libref by using a LIBNAME statement
4.2 Which type of delimited file does PROC IMPORT read by default?
a. logical record-length files
b. varying record-length files
c. fixed record-length files
d. illogical record-length files - Answer- Correct answer: b
By default, the IMPORT procedure reads delimited files as varying record-length files
, 4.3 Which program correctly imports only the first seven observations from the external
file?
a. options obs=7;
proc import data="C:\users\test.txt"
out=exam
dbms=dlm
replace;
run;
proc print data=exam;
run;
b. proc import datafile="c:\users\test.txt"
out=exam
dbms=dlm
replace;
options obs=7;
run;
proc print data=exam;
run;
c. proc import datafile="c:\users\test.txt"
out=exam
dbms=dlm
replace;
run;
proc print data=exam (obs=7);
run;
d. proc import datafile="c:\users\test.txt"
out=exam
dbms=dlm
replace;
run;
proc print data=exam;
options obs=7;
run; - Answer- Correct answer: a
Use the OBS= option in the OPTIONS statement before the IMPORT procedure to limit
the number of observations that SAS reads from the external file
4.4 Which of the following pieces of information does SAS need in the DATA step in
order to read an Excel workbook file?
a. a libref to reference the Excel workbook to be read
b. the name and location (using another libref) of the new SAS data set
c. the name of the Excel worksheet that is to be read
d. all of the above - Answer- Correct answer: d
To read an Excel workbook file, SAS must receive the following information in the DATA
step: a libref to reference the Excel workbook to be read, the name and
Chapter location (using another libref) of the new SAS data set, and the name of the
Excel worksheet that is to be read