Commonly Asked SAS Interview Questions with Answer : 41 - 45

Ques 41 : Which one is most efficient : WHERE Statement or WHERE data set option ?

Ans : The 'WHERE = ' SAS dataset option is more efficient than WHERE Statement.

'Where' dataset option would transfer only those observations to PDV which match the conditional test. 

* We should not use 'FIRSTOBS=' and 'OBS=' options with WHERE Statement or WHERE option

* If both WHERE Statement and WHERE option are used in same data step then where statement would get ignored by SAS



Ques 42 : How can we create user-defined formats ?

Ans : We can create user-defined format by PROC FORMAT procedure.



Ques 43 : How could we see the physical location of any library and any dataset ?

Ans : There are some files in SAS library 'SASHELP'  by the name 'VSLIB' and 'VSTABLE' which contains the physical locations of library and datasets respectively.



Ques 44 : How do we list all SAS system options and can you list only specific one as well.

Ans : We can use PROC OPTIONS procedure to list sas system options.

To list all SAS system options :
                                                        PROC OPTIONS;
                                                        RUN;

To list specific SAS system option ;


PROC OPTIONS OPTION= ERRORS;
                          RUN;

* SAS System options would get printed into log



Ques 45 : How could we reset the SAS system option's default value to specific one ?

Ans : We can reset the SAS system option's value by using OPTIONS option.

OPTIONS ERRORS = 5;

Commonly Asked SAS Interview Questions with Answer : 36 - 40

Ques 36 : How to get the default or sample datasets or sample library into SAS.

Ans : In SAS, sample library is SAMPSIO which is set by default in configuration file. We can get the sample datasets from this library by several ways but the easiest way is :

PROC DATASETS LIBRARY=SAMPSIO;
                       RUN;



Ques 37 : How to copy an entire library to new destination with it's all attributes ?

Ans : We can use COPY statement with Proc Datasets procedure to copy an entire library.

PROC DATASETS LIBRARY= SOURCE;
                       COPY OUT = Destination;



Ques 38 : How to copy a dataset from one library to another library ?

Ans : The simplest way to copy a dataset from one library to another library is to use COPY procedure.

                PROC COPY IN = Uma OUT = Shanker;
                SELECT Dsn ;
                RUN;

* DSN dataset has been copied to 'Shanker' library from 'Uma' library.



Ques 39 : What is the specific condition when SAS does not create INPUT BUFFER ?

Ans : While creating a new dataset, if the input file is a sas dataset then SAS does not create an INPUT BUFFER. In this condition SAS writes the input data directly to the PDV.



Ques 40 : If a SAS code has too many errors, then how many errors SAS would print into its log ?

Ans : SAS prints 20 errors by default for a SAS code. We can also set the number of errors to be get printed into log by using SAS System option.

OPTIONS ERRORS = 5;

* This option is also useful to save log space. In the same way, if we don't want NOTES to print into log then we can use OPTIONS NONOTES

* There is no SAS OPTION is available to eliminate the warning messages.

Commonly Asked SAS Interview Questions with Answer : 31 -35

Quse 31 : By using PROC SQL, How could we get the correct count of data from that column which includes duplicates  ?

Ans : We can use DISTINCT keyword with an aggregate function in PROC SQL to get the count of non-duplicate data.

          PROC SQL;
          SELECT Count (DISTINCT Fname) as Count
          FROM Uma.DSN;
          QUIT;

Note : if some values are missing in Fname that would also not get counted here.



Ques 32 : What are the basic differences between HAVING and WHERE clause in PROC SQL ?

Ans : 1. Having clause works on Grouped data while Where clause affects individual rows.

2. Having Clause processes the data after the Group by clause and any aggregate functions process

3. Where clause process the data before Group by clause and any aggregate function process the data.



Ques 33 : What is the use of VALIDATE statement in PROC SQL;

Ans : In PROC SQL, VALIDATE statement is the statement which cross check the query's syntax that syntax is correct or not without submitting it.
In log, SAS displays about the syntax whether it is correct or not.

                  PROC SQL;
                  VALIDATE SELECT Name, EmpID
                  FROM Uma.DSN;
                  QUIT;



Ques 34 :  What do you understand by Join or Joining the tables in PROC SQL ?

Ans : Joining Tables gives us the facility to fetch the data from two or more tables. It does not alter the original tables.



Ques 35 : What are the effects of Null values in JOINS in PROC SQL ?

Ans : PROC SQL behaves with Null values like missing values and same in joins. 
It means if we specify any null value in PROC SQL join then it would be matched with other null value of the same type of it's own (Character or numeric ).