Mindmajix

Base SAS Interview Questions

Base SAS Interview Questions

Q. What resources are used to run a SAS program?

The six resources used to run a SAS program are:

a) Programmer time:The amount of time taken by the programmer for writing, testing and maintaining the program

b) Real time:The time elapsed while executing a job

c) CPU time:The amount of time the CPU takes to perform a task. The task can be reading data, writing data, calculations or implementation of a logic

d) Memory:The work area memory space used for holding executable programs, data, etc

e) Data storage space:The disk space for storing the data. This is measured in terms of bytes, kilobytes, gigabytes etc

f) I/O:The read and write operations performed to movie data from the memory to any output device, and vice versa


Q. List the factors that need to be considered while assessing the technical environment.

The four factors that need to be considered while assessing a technical environment are:

a) Hardware: Available memory, number of CPU’s, number of devices connected, network bandwidth, I/O bandwidth, and capability to upgrade

b) Operating environment:The resource allocation & I/O methods

c) System load:This includes the number of users sharing the system, the network traffic, and thepredicted increase in load

d) SAS environment:includes all SAS software products installed, number of CPU’s, and memory allocated for SAS programming


Q. Explain the functionality of the system option STIMER in the Windows environment.

STIMER option in the Windows environment specifies that CPU time and real time statistics are tracked and written to the SAS log throughout the SAS session.

Example: The following line of code turns on the STIMER option

options STIMER;


Q. What is the function of the option FULLSTIMER in the Windows operating environment?

FULLSTIMER option in the Windows environment specifies that all the available resource usage statistics needs to be tracked and written to SAS log throughout the SAS session.

Example:

options FULLSTIMER;


Q. Explain the MEMRPT option.

The MEMRPT option in the z/OS environment specifies that the memory usage statistics are tracked and written to SAS log throughout the SAS session. This is not available as a separate option in the Windows operating environment.


Q. While benchmarking the programming techniques in SAS, why is it necessary to execute each programming technique in separate sessions?

It is always necessary to execute each programming technique in separate SAS sessions while benchmarking them the first time a program is read because the operating system might load the code into the cache and retrieve it from the cache when it is referenced. This takes less time. The resource usage necessary to perform this action is referred to as overhead. Using separate sessionsminimize the effect of overhead on resource statistics.


Q. While doing benchmark tests, when is it advisable to run the code for each programming technique several times?

It is advised to run the code for each programming technique several times while benchmarking tests if the system is executing other jobs at the same time. Running the code several times reduces variations in the resource consumption associated with the task and so the average resource usage is known.


Q. How do you turn off the FULLSTIMER option?

The FULLSTIMER option can be turned off with the following line of code.

options nofullstimer;


Q. What steps can be taken to reduce the programmer time?

Programmer Time is the amount of time required for the programmer to determine the specifications, write, submit, test and maintain the program. It is difficult to calculate the exact time, but it can be reduced by the use of well-documented programming practices and reuse of SAS code modules.


Memory Usage


Q. What is the sequence of action performed in the background while trying to create a data set from another data set?

While creating a data set from another data set the following actions take place in the background

a) The data gets copied from the input data set to a buffer in memory

b) From the input buffer an observation at a time is written to PDV (Program Data Vector)

c) Each observation from PDV is written to output buffer when processing is complete

d) The contents of output buffer are written to disk when the buffer is full


Q. Define page and page size.

A page is a unit that indicates the data transfer between a storage device and Page size is the amount of data that can be transferred to one buffer in a single I/O operation.


Q. What procedure is used to indicate the page size of a data set?

The Contents procedure is used to know the page size associated with a data set.

Example: The following Contents procedure issues a message to SAS log indicating the page size associated with the data set exam.clinic1. This also gives the number of data set pages.

Proc contents data = exam.clinic1;

run;


Q. Is it possible to control the page size of an output data set?

It is possible to control the page size of an output data set by using BUFSIZE= option, whichspecifies the page size in bytes

Example: The following program creates a data set exam.clinic1 from the data set exam.clinic2. In the following program the BUFSIZE= option specifies a page size of 30720 bytes.

options bufsize=30720;

libname exam ‘c:\myprog’;

data exam.clinic1

set exam.clinic2;

run;


Q. What is the default value of the BUFSIZE= option?

The default value of the BUFSIZE= option is 0. If BUFSIZE= option is set to zero SAS uses the optimal page size determined by SAS for that operating environment.


Q. Is it necessary to specify the BUFSIZE= option every time a data set is processed?

No. The BUFSIZE= option is set at the time of creation of data set, and that value of becomes a permanent attribute of the data set. Once it is specified it is used every time the data set is processed.


Q. Explain the significance of BUFNO= option.

BUFNO= option can be used to specify the number of buffers that are available for reading or writing a SAS data set. It is possible to control the number of pages of data e loaded into the memory with each I/O transfer using this option.

Example: The following program creates a data set exam.clinic1 from the data set exam.clinic2. In the following program the BUFNO= option is given a value of 4, which specifies that 4 buffers are available.

options bufno=4;

libname exam ‘c:\myprog’;

data exam.clinic1

set exam.clinic2;

run;


Q. How do you set the BUFNO= option to the maximum possible number?

BUFNO= option can be set to maximum value by giving the value of max in the BUFNO= option. This sets the number of buffers to maximum possible value in the operating environment which is the largest four byte signed integer which is ((2^31)-1) approximately 2 billion.

Example: The following program creates a data set exam.clinic1 from the data set exam.clinic2.In the following program the BUFNO= option is given a value of 4 which specifies that 4 buffers are available.

options bufno=4;

libname exam ‘c:\myprog’;

data exam.clinic1

set exam.clinic2;

run;


Q. Is it necessary to specify the BUFNO= option every time a data set is processed?

Yes the buffer number is not a permanent attribute of a data set and is valid only for the current SAS session in which it is set.


Q. What are the general guidelines for specifying the buffer size and buffer number in the case of small data sets?

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.


Q. How does the BUFSIZE= and BUFNO= impact the following program?

data exam.clinic1 (bufsize=12288 bufno=10);

set exam.clinic2;

run;

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.


Q. Explain the SASFILE statement.

The SASFILE statement is used to hold a SAS data file in memory so that data is available to all subsequent program steps. This reduces the allocation and freeing of memory for buffers.

Example: In the following program the SASFILE statement opens the data set exam.clinic1, allocates the buffer, and reads the data into the memory so it is available to both the proc print as well as the proc means step. The last SASFILE statement closes the SAS data file and makes the buffers free.

sasfile exam.clinic1 load;

proc print data= exam.clinic1

var slno result;

run;

proc means data= exam.clinic1;

run;

sasfile exam.clinic1 close;


Q. What happens if the size of the file in the memory increases during the execution of SASFILE statement?

During the execution of a SASFILE statement SAS allocates the number of buffers based on the number of pages required for the SAS data file and the index file. Once the data file is held in the memory any update operation can be performed. If the files in the memory increase in size during processing then the number of buffers associated also increases.


Q. Mention the guidelines to be followed while using SASFILE statement.

The following guidelines are followed while using SASFILE statement:

a) Care must be taken to ensure there is sufficient real memory

b) If there is a data file that does not fit into memory completely, then use the data step with the SASFILE statement to create a subset of the file that fits into memory. This saves CPU time since a part of the file resides in memory. Other parts can be processed quickly


Q. How is free buffer allocated by the SASFILE statement?

The SASFILE statement opens the data file and allocates enough buffers to hold the data in memory. These buffers can be released only when:

a) SASFILE CLOSE statement is used.

Example: In the following program example the SASFILE statement opens the data set exam.clinic1 then allocates the buffer, reads the data into the memory, and it is available to both the proc print as well as proc means step. The last SASFILE statement closes the SAS data file and frees the buffers.

sasfile exam.clinic1 load;

proc print data= exam.clinic1

var slno result;

run;

proc means data= exam.clinic1;

run;

sasfile exam.clinic1 close;

b) SAS session ends so it frees the buffers and closes the file.


Q. Which operations are not allowed in a file opened with SASFILE statement?

There are certain operations that cannot be performed on a file opened with sasfile statement, such as replacing the file and renaming the variables.


Q. How do you calculate the total number of bytes occupied by a data file if you know the page size?

The total number of bytes that a data file occupies can be calculated by multiplying the page size by the number of pages.

Example: If the data file exam.clinic1 has a page size of 8192 and number of pages is 900, then the data file occupies 7372800 bytes (8192* 9423).


Data Storage Space


Q. What factors are considered by SAS when calculating the data storage space required for a SAS data file?

The following factors are considered by SAS when calculating the data storage space required for a SAS data file:

a) Storage space required by the descriptor portion

b) Storage space required by the observations

c) Any storage overhead

d) Storage space required for associated indexes


Q. How do a SAS character variable store data and what is the default length of a character variable?

SAS character variables store data as one character per byte. The default length of a character variable is 8 bytes.


Q. Which step can be taken to reduce the length of a character variable?

A length statement can be used to control the length of character variable.

Example: In the following program example the data set exam.clinic1 is created from the data set exam.clinic2. The variable, name, is assigned a value of 5. So the variable name of the data set exam.clinic1 will have a length of 5.

data exam.clinic1;

length name $ 5;

set exam.clinic2;

run;


Q. How does SAS store numeric values and what is the default length of a numericvariable?

SAS stores numeric values using double precision floating point representation (form of scientific notation). This helps with storing numbers of large magnitude and to perform computations that requires precision after the decimal point. The default length of numeric variables is 8 bytes.


Q. Explain the significance of PROC COMPARE.

PROC COMPARE is used to compare the contents of two SAS data sets. It compares the following:

a) Data set attributes

b) Variables

c) Observations

d) Variable attributes and values of matching variables

Example: The following PROC COMPARE step compares the two data sets exam.result1 and exam.result2 and prints the result in SAS log:

proc compare base= exam.result1

compare= exam.result2;

run;


Q. What all conditions make a data file an ideal candidate for compression?

A data file becomes an ideal candidate for compression if it satisfies one or more of the following conditions:

a) It is large

b) It has many missing values

c) It has many lengthy character values

d) It has repeated characters or binary zeroes

e) It has repeated values in the variable which are physically stored next to one another


Q. Explain the compression of a data set.

A SAS data file by default is uncompressed. It can be compressed to conserve disk space. A data set can be compressed by using the compress= option.

Example: The following program creates a compressed data set exam.result1 from the data set exam.result2. When the data set is created SAS writes a note to the log indicating the percentage of reduction in size obtained by compressing the data set. Here it uses the RLE (Run Length Encoding) Algorithm for compressing the data set. RLE algorithm compresses the observations by reducing the repeated consecutive characters to 2 byte or 3 byte representations.

data exam.result1 (compress= YES);

set exam.result2;

run;


Q. Which option is used for accessing an observation directly in an uncompressed data set?

The POINT= option can be used for accessing an observation directly in an uncompressed data set.

Example: The following program creates data set exam.result1 from the data set exam.result2. This program accesses the 5th observation directly from the SAS data set. Number is a temporary variable that is created and contains the observation number of observation to be read. It is assigned a value before the set statement is executed. The output statement is used to override the automatic output and write this observation directly to the data set. The stop statement is used for preventing continuous looping.

data exam.result1 ;

number=5;

set exam.result2 point=number;

output;

stop;

run;


Q. Which option is used for controlling direct access in a compressed data set?

The POINTOBS = option can be used controlling whether direct access is allowed in a compressed data set.

Example: The following program creates a compressed data set exam.result1 from the data set exam.result2. The option pointobs=yes ensures that random access to the compressed data set exam.result1 is allowed.

data exam.result1 (compress= YES pointobs= yes);

set exam.result2;

run;


Q. Once a SAS data file is compressed, is it possible to change the setting to uncompressed?

Once a data file is compressed the settings become a permanent attribute of the file. The file has to be created again to change the setting to uncompressed.


Q. Explain the significance of REUSE= option.

REUSE= option is used to specify whether SAS reuses the space when observations get added to the compressed data set. If the reuse= system option is set to YES, then SAS tracks and reuses the free space in the compressed data set which is created.

Example: The following program creates a compressed data set exam.result1 from the data set exam.result2. Since the option reuse= is set to yes SAS tracks and reuses the free space in the exam.result1 data set.

data exam.result1 (compress= YES reuse= yes);

set exam.result2;

run;


Q. What is the main difference between a SAS data file and a SAS data view?

SAS data file and SAS data view are both SAS data sets. The main difference is that SAS data file contains both descriptor information and data values. (Descriptor information refers to the details of the data set like name of the data set, number of observations, number of variables, attributes of variables.) The data view contains only descriptor information about the data and does not contain the values. The data view also contains information about how to retrieve the data.


Q. What are the sources from which SAS data view can extract the data?

SAS data view can extract the data from a variety of sources, namely a raw data file, SAS data file, PROC SQL views, SAS/access View, DB2, Oracle, or any other DBMS data.


Q. What are the main advantages of using a data step view?

The main advantages of using a data step view are as follows:

a) Creating a data step view always helps to conserve disk space by avoiding storing of large data files several times

b) It is always possible to access the most recent data

c) It helps in combining the data from multiple sources


Q. Explain how to create a data step view.

To create a data step view, use the option view= after the name of the view in the data step.

Example: The following example program creates a view exam.resultview from the file that is referenced by the fileref result. The view= option tells SAS to compile the program and store the program.

data exam.resultview / view=exam.resultview;

infile result;

run;


Q. How do you check the source statement related to a DATA step view?

The source statement related to a DATA STEP VIEW can be retained by using the describe statement. The describe statement writes a copy of the source code to SAS log.

Example: The following example uses describe statement to write the source code of the view exam.resultview to sas log.

data view=exam.resultview;

describe;

run;


Q. Is the code submitted to create a DATA STEP view executed?

No. When a data step view is created, the data step is partially compiled and the code is stored in the SAS library with a member type of view.

Example: The following example program is used to create a view exam.resultview from the file that is referenced by the fileref result. The view= option tells SAS to compile the program and not execute. This code is then stored in the library referenced by the libref exam.


Q. Explain what is SAS? What are the functions does it performs?

SAS means Statistical Analysis System, which is an integrated set of software products.

  • Information retrieval and data management
  • Writing reports and graphics
  • Statistical analysis, econometrics and data mining
  • Business planning, forecasting and decision support
  • Operation research and Project management
  • Quality Improvement
  • Data Warehousing
  • Application Development

Q. Explain what is the basic structure of SAS programing?

The basic structure of SAS are

  • Program Editor
  • Explorer Window
  • Log Window

Q. What is the basic syntax style in SAS?

To run program successfully, and you have following basic elements:

  • There should be a semi-colon at the end of every line
  • A data statement that defines your data set
  • Input statement
  • There should be at least one space between each word or statement
  • A run statement

For example: Infile ‘H: \StatHW\yourfilename.dat’;


Q. Explain what is Data Step?

The Data step creates an SAS dataset which carries the data along with a “data dictionary.” The data dictionary holds the information about the variables and their properties.


Q. Explain what is PDV?

The logical area in the memory is represented by PDV or Program Data Vector. At the time, SAS creates a database of one observation at a time. An input buffer is created at the time of compilation which holds a record from an external file. The PDV is created following the input buffer creation


Q. Mention what are the data types does SAS contain?

The data types in SAS are Numeric and Character.


Q. In SAS explain which statement does not perform automatic conversions in comparisons?

In SAS, the “where” statement does not perform automatic conversions in comparisons.


Q. Explain how you can debug and test your SAS program?

You can debug and test your SAS program by using Obs=0 and systems options to trace the program execution in log


Q. Mention what is the difference between nodupkey and nodup options?

The difference between the NODUP and NODUPKEY is that, NODUP compares all the variables in our dataset while NODUPKEY compares just the BY variables


Q. Mention the validation tools used in SAS?

For DataSet : Data set name/ debug Data set: Name/stmtchk
For Macros: Options: mprint mlogic symbolgen


Q. Explain what does PROC print, and PROC contents are used for?

To display the contents of the SAS dataset PROC print is used and also to assure that the data were read into SAS correctly. While, PROC CONTENTS display information about an SAS dataset.


Q. Explain what is the use of function Proc summary?

The syntax of proc summary is same as that of proc means, it computes descriptive statistics on numeric variables in the SAS dataset.


Q. Explain what Proc glm does?

Proc glm performs simple and multiple regression, analysis of variance (ANOVAL), analysis of covariance, multivariate analysis of variance and repeated measure analysis of variance.


Q. Explain what is SAS informats?

SAS INFORMATS are used to read, or input data from external files known as Flat Files ASCII files, text files or sequential files). The informat will tell SAS on how to read data into SAS variables.


Q. Mention the category in which SAS Informats are placed?

SAS informats are placed in three categories,

  • Character Informats : $INFORMATw
  • Numeric Informats : INFORMAT w.d
  • Date/Time Informats: INFORMAT w.

Q. What function CATX syntax does?

CATX syntax concatenate character strings remove trailing and leading blanks and inserts separators.


Q. Explain what is the use of PROC gplot?

PROC gplot has more options and can create more colorful and fancier graphics.


Q. You might be already familiar with the dataset. What is the descriptor portion of the data set?

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 attribute information for each variable in the dataset.


Q. Which parameters describe a variable in SAS?

A variable can be best described by name, type, length, format, informat and label in SAS.


Q. How does SAS recognise the end of a step and execute the previous step?

Whenever SAS encounters a Data, PROC, Run or Quit statement, SAS executes the previous step.


Q. How do we reference a permanent SAS data set?

A permanent SAS data set can be referenced by a two level name-`libref. filename’. libref is the name of the library to which SAS file belongs and filename is the name of the data set. A period separates both libref and filename. E.g.: To reference a SAS data set named questionseti which is stored in the library exam, we use the two level name -exam.questionset1


Q. What is the default length of numeric variables?

Numeric variables are stored as floating point numbers in 8 bytes of storage unless we specify different length. The default length of numeric variables are 8.


Q. How do you verify after assigning a libref?

When a libname statement is submitted, 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.


Q. What is the purpose of a SAS engine?

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.


Q. Describe some ways to view the contents of SAS data set?

There are three ways for viewing the contents of a SAS data set – Proc contents, Proc data sets and opening the libraries folder in the explored window. Eg : To view the contents of a dataset cquestionset2′ stored in the library ‘exam’ the following programs can be used.

proc contents data=exam.questionset2;

 run;

OR

proc datasets;

contents data=exam.questionset2;

quit;


Q. Which option is used to list the variables in creation order or order of logical position while viewing the dataset with proc contents?

VARNUM OPTION can be used for listing the variables in logical order. By default PROC CONTENTS and PROC DATASETS 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;


Q. How do you modify SAS system options like page number, time etc?

OPTIONS STATEMENT can be submitted to modify system options. In the following example an OPTIONS statement is submitted to change the following options- date and pigeon. 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 venom;

run;


Q. How SAS handles two digit year values?

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.


Q. Suppose your dataset exam.questionset2 contains 20 observations. How do you print only the last ii observations?

This can be achieved by using FIRSTOBS=io option. SAS reads tenth observation first and then reads till the last observation.

E.g.: options firstobs=10

proc print data=exam.questionset2;

run;


Q. Suppose your dataset exam.questionset2 contains 20 observations. How do you print the observations from 12-17?

This can be achieved by combining FIRSTOBS= and OBS= option.

 E.g.:

options firstobs= 12 obs= 17;

proc print data=exam.questionset2;

run;


Q. Describe the SOURCE system option used in SAS?

The SOURCE system option controls whether SAS source statements are to be written to SAS log. The default system setting is SOURCE. The syntax is SOURCEINOSOURCE.

SOURCE – specifies to write SAS SOURCE statements to SAS log.

NOSOURCE – specifies not to write SAS SOURCE statements to SAS log.


Q. Describe the REPLACE option in detail?

This specifies that the permanently stored data sets can be replaced. If the option NOREPLACE is used the inadvertent replacing of existing datasets can be prevented.

The syntax is REPLACE INOREPLACE.

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


Q. What is the function of INCLUDE command in SAS?

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:

include ‘d: \sas \set2.sas’


Q. What are the two categories of error commonly encountered in SAS?

The two types of errors are data error 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.

E.g.:

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.


Q. Suppose after submitting a SAS program you see the statement `Data step running’ at the top of active window. What does that indicate and how do you resolve the issue?

This indicates that there is a syntax error. The error is that the data step which is submitted 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 submitting a run statement to complete the data step.


Q. How do you specify comments in SAS?

There are two ways of specifying comment statements —

* this is a comment;

Or

/* this is another comment*/


Q. How do you invoke the debugger in SAS?

The debugger can be invoked by adding debug option in data statement and then executing the program.

E.g.:

data exam.questionset2 / debug;

infile exam;

input one $ two $;

run;

proc print data=exam.questionset2;

run;


Q. How do you select the variables and control the order in which they appear while creating a list report?

This can be achieved by using VAR statement in proc print.

E.g.:

proc print data=exam.questionset2;

var slno quest’ quest2 quest3;

run;


Q. How to remove the column containing observation number while creating a list report?

Using NOOBS option in the proc print statement enables us to remove the column containing observation number while creating list report.

E.g.:

 proc print data=exam.questionset2 noobs;

var slno quest’ quest2 quest3;

run;


Q. What is the output of proc print?

proc print produces a report containing a column for observation number on the left, displays all the observations and variables in the dataset , variables in the order in which they appear in the data set.


Q. How do you cancel a title statement?

All the previous title statements can be cancelled by issuing a null title statement or submit a titles statement with no text.

 E.g.:

Title1;

proc print data=exain.questionset2 noobs;

var slno quests quest2 quest3;

 run;

The null titles statement causes the cancellation of all the titles which were previously defined before the execution of proc print.


Q. Suppose you are having a data set exam.questionset2.The data set contains a cohmm date. You have to assign a format (nunddyy8.) temporarily to the date column so that it appears in the formatted way in the output. How do you do that?

This can be achieved by using the format statement. format statement is applicable only to the proc step in which it appears.

Eg:

Title1;

proc print data = exam.questionset2 noobs;

 var slno quests quest2 quest3 date;

 format date mmddyy8.;

run;


Q. How do you assign a permanent label in SAS?

A permanent label can be assigned by using the label statement in data step. E.g.: The following program creates a data set exam.questionset3. Here the label statement is mentioned in the data step. So the label for the variable date is permanently assigned.

data exam.questionset3;

set exam.questionset2;

label date=’Finish Date’;

run;

proc print data = exam.questionset3 noobs;

run;


Q. While creating a list report with proc report how do you select the variables and order them?

This is achieved using column statement. column statement decides the order of variables while using proc report.

E.g.:

proc report data = exam.questionset2 ;

column slno quests quest2 quest3 date;

run;


Q. Which option is used with proc report statement to underline all column headings and space between them?

HEADLINE option can be used along with proc report for underlining all the column headings and space between them.

E.g.: proc report data = exam.questionset2 headline;

 column slno quests quest2 quest3 date;

run;


Q. What is the purpose of using order option in the define statement while using proc report?

While using proc report, defining a variable as an order variable produces a list report with the rows ordered according to the formatted values. Proc report displays only the first occurrence of each value of an order variable in a set of rows which has same value for all order variables.

The following examples produce a report from the data set exam.questionset2. define statement used below defines set as order variable with label `questionsetno’ and width of 6.So the report contains rows ordered by the variable set.

proc report data=exam.questionset2 headline;

 column set quests quest2 quest,3 date;

define set/ order `questionsetno’ width=6;

run;


Q. Which variables are used to calculate statistics in proc report?

Analysis variables are used to produce statistics in proc report. By default all numeric variables are considered as analysis variables and used for the calculation of default statistics- sum.


Q. What is the function of infile statement?

infile statement is used to indicate the external file in which the required data resides.

E.g:

infile’ D: \sas \programs \ questionseti.dat’ ;


Q. Which is the ideal situation for using column input?

Column input is used when data is:

a) standard numeric or character values. Standard numeric data can only contain numbers, decimal points, numbers in scientific notation and plus or minus signs.

b) in fixed columns. For each row the values for particular field begin and end in same columns.


 

Q. How do you read the data lines entered directly into the program?

DATALINES statement can be used as a last statement in the data step to read the data lines directly.

 E.g.:

data exam.questionset3;

 infile questfile;

input slno 1-4 author $ 5-12;

datalines;

This set contains formatted questions by famous authors

run;


Q. What is the purpose of using the keyword _NULL_ in the data statement?

NULL_ statement enables us to use the data step without creating a dataset. The following example uses the keyword _NULL_ to use the data step without creating a dataset. The following example uses the keyword _NULL_ to create a raw data file by reading from the dataset `exam.questionsetf. FILE statement specifies the output file location. PUT statement describes the lines to be written to the raw data file.

data _null_;

set exam.questionset1;

file `d: \sas\seti.dat’;

put setno 1-4 answers 5-25;

run;


Q. What is the purpose of PUT statement?

The PUT statement is used to describe the data to be written to a raw data file. It is analogous to the use of input statement while reading from a raw data file.

The following example illustrates the use of PUT statement to write to a raw data file referenced by the fileref `questfile’. data _null_;

set exam.questionset2;

file questfile; put shio 1-4 author 5-12;

run;


Q. Which parameters are to be mentioned in the input statement while using cohmm input?

While using column input the input statement should contain:

  1. SAS variable name
  2. Type (‘$’ sign if it is a character column)
  3. Starting column
  4. Ending column if necessary

E.g.:

Data exam. Questionset3;

Infile quwstfile;

Infile questfile;

Input slno 1-4 uthor $ 5-12;


Q. Difference between INPUT and INFILE

The INFILE statement is used to identify an external file while the INPUT statment is used to describe your variables.

Note : The variable name, followed by $ (dollar sign), idenfities the variable type ascharacter.

In the example shown above, ID and SEX are numeric variables and Name a character variable.


Q. Difference between Informat and Format

Informats read the data while Formats write the data.

Informat – To tell SAS that a number should be read in a particular format.

For example: the informat mmddyy6. tells SAS to read the number 121713 as the date December 17, 2013.

Format – To tell SAS how to print the variables.


0 Responses on Base SAS Interview Questions"

Leave a Message

Your email address will not be published. Required fields are marked *

Copy Rights Reserved © Mindmajix.com All rights reserved. Disclaimer.
Course Adviser

Fill your details, course adviser will reach you.