Friday, 23 December 2016

Proc Print:

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
  1. Firstobs indicates the starting number of observation to be printed
  2. Obs indicates the ending number of observation to be printed
  3. Drop indicates the variables to be dropped
  4. Keep indicates the variables to be keep
  5. Split ='split character' - splits labels as column headings across multiple lines where split character appears
  6. Double - double spaces the printed output
  7. Label - uses variable labels as column headings (variable name is default heading)
  8. N - Lists no: of observations in the specified datasets
  9. Noobs - suppresses the observation number in the output.
  10.  Id -Identify observations by the formatted values of the variables which can be listed instead of observation numbers
  11. Var -Select variables that appear in the report and determine their order
  12. By - Produce a separate section of the report for each BY group
  13.  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

No comments:

Post a Comment