0% found this document useful (0 votes)
841 views22 pages

Base SAS Interview Questions You'll Most Likely Be Asked

Base SAS Interview Questions You’ll Most Likely Be Asked is a perfect companion to stand ahead above the rest in today’s competitive job market. Rather than going through comprehensive, textbook-sized reference guides, this book includes only the information required immediately for job search to build an IT career. This book puts the interviewee in the driver’s seat and helps them steer their way to impress the interviewer.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
841 views22 pages

Base SAS Interview Questions You'll Most Likely Be Asked

Base SAS Interview Questions You’ll Most Likely Be Asked is a perfect companion to stand ahead above the rest in today’s competitive job market. Rather than going through comprehensive, textbook-sized reference guides, this book includes only the information required immediately for job search to build an IT career. This book puts the interviewee in the driver’s seat and helps them steer their way to impress the interviewer.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

Base SAS

Interview Questions
Review these typical interview questions and think about how you would
answer them. Read the answers listed; you will find best possible answers
along with strategies and suggestions.
This page is intentionally left blank
Chapter 1

Basics

1: Explain SAS and its functions.


Answer:
SAS is a popular Statistical Analysis System used for data
analytics. It contains a set of software tools that are well integrated
to extract, compile and process the data including Big Data. SAS
performs the following functions:
a) Data Warehousing
b) Statistical scrutiny of the information, data mining and
metrics
c) Helps the businesses in planning and forecasting
d) Provides statistical data for decision-making
e) Retrieving and managing useful business information
f) Presenting the available information as reports and
graphics
g) Process research and Project management
h) Improving Quality by providing valuable insights
i) Application Development

2: What are the different types of output produced by SAS?


Answer:
A SAS program can typically produce one or more of the
following outputs:
a) A SAS Data Set a temporary or permanent table that
contains the observations and variables.
b) A Report or Listing a list of information or a DATA SET or
a summary report containing the information/statistics.
c) SAS Log a log file that contains the list of statements used
and the corresponding results or messages from SAS. The
log can also be a display on screen or printout.
d) Catalogue Graphs and other output produced by the SAS
program which cannot be stored as a Data Set can be
included in the catalogue.
e) External file or database such as Oracle or MS Access
which can be accessed and modified by SAS programs.
f) ODS Output Apart from these, the SAS Output Delivery
System can produce outputs in HTML, PostScript, and RTF
formats in addition to SAS listings and Data Sets.

3: You might be already familiar with the Data Set. What is the
descriptor portion of the Data Set?
Answer:
Descriptor portion of the Data Set contains information about the
Data Set like name of the Data Set, date and time when it was
created, number of observation, number of variables and a ribute
information for each variable in the Data Set.

4: Which parameters describe a variable in SAS?


Answer:
A variable can be best described by its Length, Type, Name, Label,
FORMAT and INFORMAT in SAS.

5: How does SAS recognise the end of a step and execute the
previous step?
Answer:
Whenever SAS encounters a DATA, PROC, RUN or QUIT
statement, SAS executes the previous step.

6: How can a permanent SAS Data Set be referenced?


Answer:
A permanent SAS Data Set can be referenced by a 2-level name:
libref . LIBREF is library name to which SAS file belongs
and FILENAME is the Data Set name. LIBREF and FILENAME are
separated by a period.
Example: To reference a SAS Data Set named questionset1 (stored in
the library exam), we use the two-level name -exam.questionset1.

7: What is the default length of numeric variables?


Answer:
Numeric variables are stored as floating-point numbers in 8 bytes
of storage unless we specify different length. The default length of
numeric variables is 8.
Chapter 2

Referencing Files

8: How do you refer an external fi le in SAS?


Answer:
External files can be accessed in SAS programs in 3 ways using
the FILE, INFILE or %INCLUDE statements. The FILE statement
gives you direct access to the lines input using the PUT statement.
It requires the FILENAME and LIBNAME specified in the
variables of FILENAME and LIBNAME types to access the file.
The INFILE statement lets you direct access to the file without
using any other object or variable type. With INFILE, you can
directly access the file by specifying its path along with the
INFILE statement. Otherwise, it functions like the FILE statement.
While the FILE and INFILE statements give you access to each line
of its content, the %INCLUDE statement loads the entire file into
the SAS engine.
9: Explain the GSUBMIT Command.
Answer:
The GSUBMIT command is used to submit or commit the SAS
statements in the windows buffer permanently. It can also be used
to submit or commit the SAS statements in the current program.
The SAS statements in the windows buffer will not be commi ed
using the GSUBMIT while the program is still running.

10: How do you verify after assigning a LIBREF?


Answer:
When a LIBNAME statement is submi ed, a message is displayed
in log window stating that LIBREF has been successfully assigned.
Thus, checking the log window enables us to verify the LIBREF.

11: What is the purpose of a SAS engine?


Answer:
SAS engine is the set of internal instructions which SAS uses for
writing to and reading from files in the SAS library.SAS can read
or write files by using appropriate engine for that file type.

12: Describe some ways to view the contents of SAS Data Set.
Answer:
There are three ways for viewing the contents of a SAS Data Set-
PROCCONTENTS, PROC Data Sets and opening the libraries
folder in the explored window.
Example: To view the contents of a Data Set stored in
the following programs can be used.
proc contents data=exam.questionset2;
run;
OR
proc datasets;
contents data=exam.questionset2;
quit;

13: Which option is used to list the variables in creation order or


order of logical position while viewing the Data Set with PROC
CONTENTS?
Answer:
VARNUM OPTION can be used for listing the variables in logical
order. By default, PROC CONTENTS and PROC Data Sets list
variables alphabetically. Specifying VARNUM option causes the
variables to be listed in the order of logical position.
The following example illustrates the use of VARNUM option
with PROC CONTENTS.VARNUM option causes the variables in
the Data Set questionset2 to be listed in the creation order.
proc contents data=exam.questionset2 varnum;
run;

14: How do you modify SAS system options like page number,
time etc?
Answer:
OPTIONS STATEMENT can be submi ed to modify system
options.
In the following example an OPTIONS statement is submi ed to
change the following options- date and PAGENO. Since the option
is set to NODATE, SAS displays no date in the output. Also, in the
output, the numbering of the page starts from 3 since PAGENO
option is set to 3.
options nodate pageno=3;
proc contents data=exam.questionset2 varnum;
run;

15: How does SAS handles two-digit year values?


Answer:
When SAS reads two-digit year values it is interpreted based on
100-year span which starts with YEARCUTOFF=value. The
default value of YEARCUTOFF= is 1920.
It is possible to override the default value and change the value of
YEARCUTOFF= to the first year of another 100-year span.

16: Suppose your Data Set exam.questionset2 contains 20


observations. How do you print only the last 11 observations?
Answer:
This can be achieved by using FIRSTOBS=10 option. SAS reads
tenth observation first and then reads till the last observation.
Example:
options firstobs=10;
proc print data=exam.questionset2;
run;

17: Suppose your Data Set exam.questionset2 contains 20


observations. How do you print the observations from 12-17?
Answer:
This can be achieved by combining FIRSTOBS= and OBS= option.
Example:
options firstobs=12 obs=17;
proc print data=exam.questionset2;
run;

18: Describe the SOURCE system option used in SAS.


Answer:
The SOURCE system option controls whether SAS source
statements are to be wri en to SAS log. The default system se ing
is SOURCE.
The syntax is SOURCE|NOSOURCE.
SOURCE - specifies to write SAS SOURCE statements to SAS log.
NOSOURCE - specifies not to write SAS SOURCE statements to
SAS log.

19: Describe the REPLACE option in detail.


Answer:
This specifies that the permanently stored Data Sets can be
replaced. If the option NOREPLACE is used the inadvertent
replacing of existing Data Sets can be prevented.
The syntax is REPLACE|NOREPLACE.
REPLACE - specifies that a permanently stored Data Set can be
replaced with another Data Set of same name.
NOREPLACE - specifies that a permanently stored Data Set
cannot be replaced with another Data Set of same name. This
helps in preventing replacing Data Sets by mistake.
This page is intentionally left blank
Chapter 3

SAS Programs

20: What is the purpose of adding @@ in an input statement after


the variable?
Answer:
Usually, to input each record in SAS, you need a separate input
statement. With @@ at the end of an input statement, SAS will wait
to continue with the input statement. So, if you have multiple
records to input, instead of using a separate input statement for
each, you can specify it as @@ and provide the details.

21: Explain the difference between FORMAT and INFORMAT.


Answer:
INFORMAT is used to specify in the format in which a number
should be read. It is used for input specifications. FORMAT is
used to specify the printing format. It is an output specification.
You can create a user-defined format using the PROC FORMAT.

22: How is table lookup done in SAS?


Answer:
SAS allows 5 types of table lookups:
a) Direct Access using the SET statement, you can load one
or more Data Sets directly
b) Format Table the PROC Format can be used with a Data
Set to load a table
c) PROC SQL the PROC SQL can be used to load Data Set
d) Arrays by loading the table data into an array
e) Match Merging 2 lookup files and a Data Set is used up.
Both lookup files are sorted by the key and the merged data
goes into the Data Set.

23: What is the function of INCLUDE command in SAS?


Answer:
The INCLUDE command includes/opens a stored program in the
Windows operating environment. Using include command
enables us to open a stored program in the code editing window.
As this is a command there is no need to add semi-colon at the
end.
Suppose you want to include the program set2.sas which is stored
in d:\sas you can issue the following command:
\sas\
24: What are the two categories of error commonly encountered
in SAS?
Answer:
The two types of errors are data errors and syntax errors. Syntax
errors occur when the programming statements do not comply
with the rules of the language. Data errors are those errors which
occur when some data values are not suitable for the SAS
statements mentioned.
Examples:
Syntax error -One common example of a syntax error is missing a
semi-colon at the end of a SAS statement. In the following
example, semi-colon is missing in the print statement which
illustrates syntax error.
proc print data = exam.questionset2
run;
Data Error -One common example of data error is assigning a
character value to a numeric variable.

25: Suppose after submi ing a SAS program you see the
What
does that indicate and how do you resolve the issue?
Answer:
This indicates that there is a syntax error. The error is that the data
step which is submi ed does not have a RUN statement. So, the
data step does not execute and hence this message appears on the
top of active window.
This can be resolved by submi ing a RUN statement to complete
the data step.
26: How do you specify comments in SAS?
Answer:
There are two ways of specifying comment statements
* this is a comment;
Or
/* this is another comment*/

27: How do you invoke the debugger in SAS?


Answer:
The debugger can be invoked by adding debug option in data
statement and then executing the program.
Example:
data exam.questionset2 / debug;
infile exam;
input one $ two $;
run;
proc print data=exam.questionset2;
run;

You might also like