SAS Interview Question with Answer : 86 and 87

Ques 86 : 
Suppose we have a dataset (One) which contains 100 numeric variables like V1, V2, V3.....V100. Create a new dataset (Two) with new variables N1, N2, N3,.....N98 with following condition :
N1 - Stores the sum of value V1, V2, V3
N2 - Stores the sum of value V2, V3, V4
N3 - Stores the sum of value V3, V4, V5
.
.
.
.
N98 - Stores the sum of value V98, V99, V100.


Ans : Firstly i have created dataset One with following array code :

and the output of dataset one is as below :


Now code for desired dataset (Two):



and the output is as desired :




Ques 87 : What would happen, if we don't supply the third argument (Length) in SUBSTR function ?

Ans :  If we omit the third argument from SUBSTR function then in result, it would return all the characters from the string, starting from the starting position (Second argument) of SUBSTR function.

We can use following syntax : 


Output :



Commonly Asked SAS Interview Questions with Answer : 81 - 85

Ques 81 : What is the way to insert a blank line after every n observation in SAS while listing a report ?

Ans : As we know that the default reports are difficult to read but it would be easier to read if a blank line would get inserted after every few observations.

We can insert a blank line by using BLANKLINE option in Proc Print statement.

Suppose we want to insert a blank line after every five observation then we can use following syntax :





Ques 82 : How could we filter the data based on multiple values for the same variable ?

Ans : We can filter the data on multiple values for the same variable by using OR or IN operator.

Syntax for OR operator : 




Syntax for IN operator :


  • We would get the same output by using OR Operator or IN Operator



Ques 83 : How could we filter the missing data even if we are not sure whether the variable is character or numeric ?

Ans :  If we are not aware about the data type of the variable and we need to filter it by missing observations, we can use IS MISSING with WHERE Statement in SAS.




Ques 84 : How to create a SAS dataset which consists all SAS system options which are currently in effect ?

Ans : We have two ways to get the list of all SAS System options which are currently in use.

1. By using SAS Procedure :


2. By dictionary tables : 





Quse 85 : How could we control the delimiter within the a Date ?

Ans : To control the delimiter within the Date, we have specific SAS Date Formats. We can use desired SAS Date format for required output. 

For Example, if we want to apply Colon (:) delimiter within SAS Date then we can use DDMMYYC10. Date format.



some more delimited SAS Date formats are :
  • For Slash (/) : MMDDYY10.
  • For Dash (-) : DDMMYYD10.
  • For Point (.) : DDMMYYP10.

Commonly Asked SAS Interview Questions with Answer : 76 - 80

Ques 76 : What is the difference between file extension .SAS and .LST in SAS ?

Ans : File extension is an identifier for type of file. There are several types of file extensions for SAS files. I am just specifying some of them.

  1. x.SAS                  :  SAS Program file
  2. x.CFG                 : SAS Configuration file
  3. x.LST                  : SAS Output file
  4. x.LOG                 : SAS Log file
  5. x.SAS7BPGM    : SAS Stored Program file
  6. x.SAS7BDAT     : SAS Data Set file
  7. x.SAS7BVEW    : SAS Data Set View file
  8. x.SAS7BCAT     : SAS Catalog file
  9. x.SAS7BUTL     : SAS Utility file
  10. x.SAS7BNDX    : SAS Data Set Index file
  • x is a name of file



Ques 77 : What is the default action of Frequency Procedure (Proc Freq) ?

Ans :  The default action of Frequency Procedure is to calculate frequencies on each variable irrespective of character or numeric of defined SAS data set.  

It means we can use PROC FREQ to compute frequencies for both character and numeric variables.

By default Proc Freq calculates four statistics on each variable which are Frequency, Percent, Cumulative Frequency and Cumulative Percent.
  • Proc Freq is not only a descriptive procedure as well as a statistical procedure which produces one way and n-way frequency tables


Ques 78 : How to get the output in List format rather than as a Cross Tabulation in Proc Freq ?

Ans : We can specify LIST option in Proc Freq to print the table in list format.



Ques 79 : How do we get to know that which SAS products are licensed and Installed at our machine ?

Ans : We can use Setinit Procedure (Proc Setinit) to get to know about licensed SAS products for our machine. 

Most of the time, we may have some SAS products licensed but not installed so to get to know only installed products we can use Product_Status Procedure (Proc Product_status).

Syntax : 

Ques 80 : How could we count the number of missing values of numeric variable in SAS ?

Ans : We can count the number of missing values for numeric variables by using NMISS option in PROC MEANS. 

Proc Means requires at least one numeric variable to calculate statistics.

Syntax :