Proc Print:
Prints a listing of the values of some or all of the variables in a SAS data set
Syntax:
proc print data = libref .Datasetname [ (firstobs = n obs = n) split = ‘Special Character’
double label n noobs ] ;
[ Id Variable list ;
Var Variable list ;
By Variable list ;
Sum Varibale list
]
Run ;
Where,
- ‘[ ]’ are optionals
- Libref is the library in which Datasetname is the dataset whose values are to be printed
- Firstobs indicates the starting number of observation to be printed
- Obs indicates the ending number of observation to be printed
- Drop indicates the variables to be dropped
- Keep indicates the variables to be keep
- Split ='split character' - splits labels as column headings across multiple lines where split character appears
- Double - double spaces the printed output
- Label - uses variable labels as column headings (variable name is default heading)
- N - Lists no: of observations in the specified datasets
- Noobs - suppresses the observation number in the output.
- Id -Identify observations by the formatted values of the variables which can be listed instead of observation numbers
- Var -Select variables that appear in the report and determine their order
- By - Produce a separate section of the report for each BY group
- Sum - Total values of numeric variables
Example:
proc print data = candy_products (firstobs=1 obs=16 ) n noobs double label ;
id Prodid ;
var Prodid Product Category Retail_price ;
by Category ;
Sum Retail_price ;
Run ;
Here,
- Candy_products is the dataset which is present in work library
- First observation to 16thobservation are printed (firstobs=1 and obs=16)
- N gives the number of observation
- Double - Double spacing between observations printed (only in list input)
- Label - Prints the label of each variable instead of variable names
- Id - Prodid becomes the row identifier instead of observation no:
- Var - Only the variables indicated here are printed
- By - The outputs are grouped by category
- Sum - Sum of the Retail_price