Saturday, October 8, 2016

SAS online courses from Penn State

Basic:
https://onlinecourses.science.psu.edu/stat480/node/7

Intermediate:
https://onlinecourses.science.psu.edu/stat481/node/6

Advanced topics:
https://onlinecourses.science.psu.edu/stat482/

Finding First and Last Observations

  • In a drug dataset, records are available of patients taken drugs on different days. 
  • We want to find out what was the first visit of the patient and last visit of the patient and check his weight.
  • Steps to find out first and last observations:
    • Sort the drug dataset by patient isr.
    • Use Set and By and find the first and last observations.
    • The First and Last observations will be available as new columns with values 1 in the newly created dataset.
  • Remember, You have to "use a BY statement, in conjunction with a SET statement, to identify the first and last observations among a group of observations".

What is the benefit of specifying the OPTIONS?

You can enhance the appearance of your output by specifying SAS system options on the OPTIONS statement.

OPTIONS option(s);

NONUMBER - to suppress the output page numbers
NUMBER - to resume the output page numbers
PAGENO=5- resetting the next output page number
NOCENTER - removes center align if any and left aligns the output and output titles
CENTER - centers the output and output titles
PAGESIZE=40 - number of lines per page in the printed output
LINESIZE-120 - number of characters per line in the printed output
NODATE - removes the automatic date added by SAS in the top of the output
DATE - sets the automatic date that will be added by SAS
ORIENTATION=LANDSCAPE- prints the output in the horizontal mode
ORIENTATION=PORTRAIT - prints the output in the vertical mode
Read more:
https://support.sas.com/documentation/cdl/en/basess/58133/HTML/default/viewer.htm#a001782263.htm

Saturday, October 1, 2016

Auto Macro Variables

 Every time you invoke SAS, the macro processor automatically creates certain macro variables. You can use these variables in your programs. The most common automatic macro variables are &SYSDATE, &SYSDAY, etc.