Using Automatic Macro Variables

Overview

SAS creates and defines several automatic macro variables for you. Automatic macro variables contain information about your computing environment, such as the date and time of the session, and the version of SAS that you are running. These automatic macro variables
  • are created when SAS is invoked
  • are global (always available)
  • are usually assigned values by SAS
  • can be assigned values by the user in some cases.
Some automatic macro variables have fixed values that are set when SAS is invoked.
Name
Value
SYSDATE
the date of the SAS invocation (DATE7.)
SYSDATE9
the date of the SAS invocation (DATE9.)
SYSDAY
the day of the week of the SAS invocation
SYSTIME
the time of the SAS invocation
SYSENV
FORE (interactive execution) or BACK (noninteractive or batch execution)
SYSSCP
an abbreviation for the operating system that is being used, such as WIN or LINUX
SYSVER
the release of SAS that is being used
SYSJOBID
an identifier for the current SAS session or for the current batch job (the user ID or job name for mainframe systems, the process ID (PID) for other systems)
Some automatic macro variables have values that automatically change based on submitted SAS statements.
Name
Value
SYSLAST
the name of the most recently created SAS data set, in the form LIBREF.NAME. This value is always stored in all capital letters. If no data set has been created, the value is _NULL_
Note: Throughout this book, the keyword _NULL_ is often used in place of the data set name in sample programs. Using _NULL_ suppresses the creation of an output data set. Using _NULL_ when benchmarking enables you to determine what resources are used to read a SAS data set.
SYSPARM
text that is specified when SAS is invoked
SYSERR
contains a return code status that is set by the DATA step and some SAS procedures to indicate whether the step or procedure executed successfully

Example

You can substitute system information such as the time, day, and date on which your SAS session was invoked and the version of SAS that you are running in footnotes for a report.
footnote1 "Created &systime &sysday, &sysdate9";
footnote2 "on the &sysscp system using Release &sysver";
title "REVENUES FOR DALLAS TRAINING CENTER";
proc tabulate data=sasuser.all(keep=location course_title fee);
   where upcase(location)="DALLAS";
         class course_title;
         var fee;
         table course_title=" " all="TOTALS",
               fee=" "*(n*f=3. sum*f=dollar10.)
               / rts=30 box="COURSE";
run;
Course information
  1. time of day (SYSTIME)
  2. day of the week (SYSDAY)
  3. date (day, month, and year) (SYSDATE9)
  4. operating environment (SYSSCP)
  5. release of SAS (SYSVER)
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.253.198