Showing posts with label Proc contents. Show all posts
Showing posts with label Proc contents. Show all posts

Commonly Asked SAS Interview Questions with Answer : 11 -15

Ques 11 : What is Format and Informat in SAS ?

Ans : In a simple word, when we are writing or printing the data from the SAS, we use Format to read the data as required and when we write the data to the SAS, we can use Informat to read the data by the SAS as required.
My favourite one liner : Informats are to read the data by SAS and Formats are to write the data by SAS.




Ques 12 : What is the type of variable in SAS ?

Ans : A Variable type is either character or numeric in SAS and each variable has a name that conforms to SAS naming conventions.



Ques 13 : How we could get the Descriptor information of an individual SAS dataset ?

Ans : We can use PROC CONTENTS (Procedure) to create SAS output which would describe the contents of the library and descriptor information of an individual SAS dataset.

Syntax : PROC CONTENTS DATA = Libref._ALL_ NODS ;                                  Run;



Quest 14 : If we use "Contents" Statement with PROC DATASETS, then what could be the result ?

Ans : The result would be same as Proc Contents (Procedure).
PROC DATASETS with Contents Statement is to view the contents of a SAS library or the descriptor information of a dataset.

Syntax :  PROC DATASETS;
                Contents Data = Libref._All_ Nodetails; 
                Quit ;



Ques 15 : How can we copy an entire SAS Library to other location ?

Ans : With the help of PROC DATASETS we can copy an entire SAS Library to other location.

Syntax :      Proc Datasets Library = Source;
                    Copy Out = Destination;
                    Quit;

To Calculate The Size Of SAS DataSet BY Proc Contents

Hi,

 For most of the cases to optimize the system, we would be in need of the size of the data set, to set some SAS System options like : SORTSIZE, MEMSIZE, REALMEMSIZE etc.

 To Calculate size of any SAS dataset:-

 For example we want to calculate the size of a data set named as "Calculate" which one is in library named as "Base". Just create the data set that contains one observation and all the number of variables we are in need.

                                                        Data base.Calculate;

                                                        input name $18. Age 2. Salary 6. ;

                                                        Cards;

                                                        Uma Shanker Saini 30 300000

                                                         ;

                                                         run;

                                                         Proc print;

                                                         run;

 Now run the CONTENTS procedure with the data set "Calculate".

                                                      Proc contents data=Base.Calculate;

                                                      Run;

Calculate

Calculate1

The size of the Calculate data set would depend on the data set page size and the total number of observation in  data set.

Formula to calculate :-

 Number of data pages =  1 + (floor( observations / Max observation per page))

Size = 256 + ( Data set page size * number of data pages)

 * floor is a function which is to round the value

 Now as per our example :

 Number of data pages = 1 + (floor(1/101))

 Data set size = 256 + 4096*1 = 4352

 Thus the Calculate data set uses 4,352 bytes of storage space.