Commonly Asked SAS Interview Questions with Answer : 45 - 50

Ques 45 : What is the difference between INTCK and INTNX function in SAS ?

Ans : In SAS, INTCK function calculates the number of interval between to dates while INTNX function calculates the date of a given number of intervals.

Suppose today is '01JAN2015' then by INTCK we can calculate that there are '364' days in between today and '31DEC2015'.

While if we want to get the date just after '364' days from today (01JAN2015) then by INTNX the result would be '31DEC2015'.

DATA DSN;
FORMAT INTNX1 date9.;
INTCK1=INTCK('Days','01JAN2015'd,'31DEC2015'd);
INTNX1=INTNX('Days','01jan2015'd,364);
Run;



Ques 46 : Which SAS Statement is more useful or efficient : WHERE or IF ?

Ans : WHERE statement is more useful in SAS in comparison to IF statement. We can use WHERE statement in Data Step as well as with SAS Procedures but we can not use IF statement in SAS Procedures.
There are several useful operators, we can use with WHERE statement given as : 'LIKE', 'CONTAINS', 'IS NULL', 'IS MISSING', 'BETWEEN AND' and so on...

* If we use more than one 'WHERE' statements condition on same variable in a same data step or proc step, then last WHERE statement will overwrite on all previous ones

* If we use more than one 'IF' statements condition on same variable in a same data step, then there would be no execution but it could get execute by using 'OR' or 'AND'

* We can not use any automatic variables created by data step (FirstDot, LastDot ,_N_ , _ERROR_) in a 'WHERE' expression



Ques 47 : What is the SAS valid date range and what would happen if someone passes the date which is outside of SAS date range ?

Ans : We are familiar with a date '01JAN1960' which is just to perform calculation on dates into SAS.

SAS dates are valid from '01JAN1582' AD to '31DEC20000' AD. 
If we pass any date prior or after of valid dates then values would get truncated.



Ques 48 : What are the various methods to combine SAS data sets ?

Ans : There are several ways to combine SAS datasets. Some methods are given below :
(A) Concatenate (B) Interleave (C) Merge (D) Update (E) Modify



Ques 49 : What would happen if we use same variable for DROP and KEEP statement in SAS ?

Ans : If same variable is specified in both 'DROP=' and 'KEEP=' statement then variable would get dropped.



Ques 50 : While concatenation of SAS dataset, which method is faster than other : PROC APPEND or SET Statement ?

Ans : SAS Procedure PROC APPEND concatenates much faster than the SET Statement because Proc Append does not process the observations from the base data set.

* We can use any number of datasets with SET statement but for PROC APPEND we can use only two datasets

* We can specified upto 50 SAS datasets in a single SET statement

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.