LOADING

Type to search

SAS Studio Workshop – Proc Content

To Know more about the Different Corporate Training & Consulting Visit our website www.Instrovate.com Or Email : info@instrovate.com or WhatsApp / Call at +91 74289 52788

Data Analytics SAS

SAS Studio Workshop – Proc Content

Share

SAS Studio Overview :

First , we create a new folder to store SAS datasets . We click on “Server Files and Folders ” tab on left viewing pane of SAS window as :

SAS Studio Workshop - Proc Content 29

 

We click on Files(Home) to open files stored in it . We right click on Files tab and click on New and then click on Folder to create a new folder .

SAS Studio Workshop - Proc Content 30

It will open the following pane as :

SAS Studio Workshop - Proc Content 31

We give the name of folder and click on Save button to save the folder .

SAS Studio Workshop - Proc Content 32

We can upload files by right click on learn folder and click on Upload Files as:

SAS Studio Workshop - Proc Content 33

 

It will open following pane :

 

SAS Studio Workshop - Proc Content 34

 

We can click on Choose Files button to choose SAS dataset to upload . It open following open pane :

 

SAS Studio Workshop - Proc Content 35

We can choose SAS dataset and click on Open button . It will upload dataset in learn folder. You can see we upload lots of SAS dataset in learn folder.

SAS Studio Workshop - Proc Content 36

 

We right click on lean folder and click on Create tab and then click on Library to create a new library to store SAS dataset .

SAS Studio Workshop - Proc Content 37

 

It will open given pane :

SAS Studio Workshop - Proc Content 38

 

We create a new library “LEARN” . We give the name of library and click on OK button to create it. We  can checked the Re-create option to recreate the library whenever we start our SAS studio . We can see LEARN library in Libraries tab under My Libraries as :

SAS Studio Workshop - Proc Content 39

We can use any of SAS files under LEARN library to work onwards .

SAS Studio Workshop - Proc Content 40

 

The CONTENTS procedure

The CONTENT procedure allows us to create a SAS output that describes either the contents of a SAS library or the descriptor information of a SAS data set . In order to view the contents of a SAS library , we use following code :

PROC CONTENTS data = libref._ALL_ NODS;

RUN;

Where :

libref – it is the library name .

_ALL_ – option requests a listing of all the SAS files in the library .

NODS – it stands for “no details” , it is used to suppress the printing of detailed information about each file when you specify the _ALL_ option .

 

We want to explore contents of baseball dataset . We used following code :

proc contents data=learn.baseball ;

run;

It shows the number of observations in the dataset . Here , the baseball dataset contains 322 observations.

The number of variables in the dataset . Here , baseball dataset contains 22 variables.

The date and time that the dataset was created and last modified.

It shows the dataset’s variables and their attributes .

# – The original order of the variable in the columns of the dataset

Type – Whether the variable is numeric or character

Len – It represents length of the variable

Format – The assigned format of the variable

Informat – The format of the variable when it was read into SAS

Label – The label associated with variable . If variables do not have labels, this column will be identical to the variable name .

OUTPUT:

It shows alphabetic list of variables and attributes .

SAS Studio Workshop - Proc Content 41

SAS Studio Workshop - Proc Content 42

SAS Studio Workshop - Proc Content 43

 

We can use directory option to see all the dataset in learn library .

proc contents data=learn.sales directory;

run;

 

OUTPUT:

It shows Directory where datasets stored :

SAS Studio Workshop - Proc Content 44

It shows all the dataset in learn library :

SAS Studio Workshop - Proc Content 45

It shows contents of sales dataset :

SAS Studio Workshop - Proc Content 46

SAS Studio Workshop - Proc Content 47

 

We use following statements:

data = learn._all_  represents all datasets in learn library .

nods – option suppress the printing of detailed information about each dataset in learn library .

It shows only list of datasets in learn library :

proc contents data= learn._all_ nods;

run;

OUTPUT:

SAS Studio Workshop - Proc Content 48

 

We check out the attributes of dataset and variables .

proc contents data=learn.sales ;

run;

OUTPUT:

SAS Studio Workshop - Proc Content 49

SAS Studio Workshop - Proc Content 50

We used nodetails option on sales dataset . It shows same output of alphabetic list of variables and attributes .

 

proc contents data=learn.sales nodetails;

run;

OUTPUT:

SAS Studio Workshop - Proc Content 51

SAS Studio Workshop - Proc Content 52

 

We use short option to see alphabetic list of variable names .

The following code shows the alphabetic list of variable names of sales dataset :

proc contents data=learn.sales short;

run;

OUTPUT:

SAS Studio Workshop - Proc Content 53

We used varnum option to see variables in creation order with attributes .

proc contents data=learn.sales varnum ;

run;

OUTPUT:

SAS Studio Workshop - Proc Content 49

SAS Studio Workshop - Proc Content 55

 

We used combination of two options varnum and short . It shows variable names of sales dataset in creation order .

proc contents data=learn.sales varnum short;

run;

OUTPUT:

SAS Studio Workshop - Proc Content 56

We used position option to see both alphabetic and creation order list of variables and attributes .

proc contents data=learn.sales position;

run;

OUTPUT:

SAS Studio Workshop - Proc Content 57

SAS Studio Workshop - Proc Content 58

SAS Studio Workshop - Proc Content 59

 

We used two options position and short . It will show variables names in alphabetic and creation order .

proc contents data=learn.sales position short;

run;

OUTPUT:

SAS Studio Workshop - Proc Content 60

 

We use short option to show the alphabetic list of variables names of all datasets in learn library .

proc contents data=learn._all_ short;

run;

OUTPUT:

SAS Studio Workshop - Proc Content 61

SAS Studio Workshop - Proc Content 62

We use varnum option to see list of variables in creation order of all datasets in learn library .

proc contents data=learn._all_ varnum;

run;

OUTPUT:

It shows the list of datasets in learn library :

 

SAS Studio Workshop - Proc Content 63

It shows the contents of all the datasets :

SAS Studio Workshop - Proc Content 64

SAS Studio Workshop - Proc Content 65

 

We used varnum and short options to see list of variables in creation order of all datasets in learn library.

proc contents data=learn._all_ varnum short;

run;

OUTPUT:

SAS Studio Workshop - Proc Content 66

SAS Studio Workshop - Proc Content 67

We can see all the datasets in learn library with nods option .

proc contents data=learn._all_ nods;

run;

OUTPUT:

SAS Studio Workshop - Proc Content 68

 

* export the variable names and their position number into a data set called “data_info”;

We used following options as :

noprint  – to not print output in results window .

out = data_info tells SAS to save output in data_info dataset .

keep = name varnum tells SAS to keep only name and varnum variables in data_info dataset .

 

proc contents     data = sashelp.class    noprint   out = data_info (keep = name varnum);

run;

OUTPUT:

SAS Studio Workshop - Proc Content 69

 

Leave a Comment

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