SAS Programming Guidelines Interview Questions You'll Most Likely Be Asked
SAS Programming Guidelines Interview Questions You'll Most Likely Be Asked
Guidelines 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
Memory Usage
14: How would you choose between Data Step and Proc SQL?
Answer:
With small data sets, Proc SQL works better since it loads the
entire data set into the memory and works with the data. So
there’s less need to go back and forth into the database. But with
large data sets Data Step will work better as loading the entire
data set with Proc SQL will block a huge chunk of memory. Data
Step will always take one record at a time and hence, the number
of records or large volume of data will not matter as long as the
database connectivity remains good.
25: What are the general guidelines for specifying the buffer size
and buffer number in the case of small data sets?
Answer:
The main objective behind specifying the buffer size and buffer
number is to reduce the number of I/O operations. In the case of
small data sets, care must always be taken to allocate as many
buffers as there are pages in the data set. This ensures that the
entire data set can be loaded into the memory using a single I/O
operation.
26: How does the BUFSIZE= and BUFNO= impact the following
program?
data exam.clinic1 (BUFSIZE=12288 BUFNO=10);
set exam.clinic2;
run;
Answer:
The above program reads the data set exam.clinic2 and creates
exam.clinic1. The BUFSIZE= option specifies that exam.clinic1 is
created with a buffer size of 12288 bytes. The BUFNO= option
specifies that 10 pages of data are loaded into memory with each
I/O transfer.
27: Explain the SASFILE statement.
Answer:
The SASFILE statement loads the SAS data file into the memory to
be available further to the program. With SAS File you can free the
buffers. Instead, the file is loaded and kept in the system memory
with a pointer in the program to access it.
The following example explains the use of SASFILE in a simple
way. The SASFILE statement opens the data set MyExam.MyClinic
and allocates the buffer. It reads the file and loads it into the
memory so that it is available to both the PROC print as well as the
PROC MEANS step. Finally, the SASFILE data file is closed with
the close statement and the buffer is cleared.
SASFILE MyExam.MyClinic load;
proc print data= MyExam.MyClinic
var. Serial No result;
run;
proc means data= MyExam.MyClinic;
run;
SASFILE MyExam.MyClinic close;
28: What happens if the size of the file in the memory increases
during the execution of SASFILE statement?
Answer:
When the SASFILE statement is executed, SAS assigns some buffer
to the DATAFILE based on the number of pages to be loaded and
the size of the index file. Once this is done, the file data is loaded
into the memory for updates. The buffer size is automatically
increased as the file size to be saved increases. The initial buffer
memory size allocated is only the minimum memory allocated to
load the file. It automatically increases provided there’s ample
memory left in the current operating system.