Search notes:
SAS: automatic macro variables
Automatic variables start with either &af
or &sys
.
Date and time related automatic macro variables
%put sysdate: &sysdate; /* 18SEP17 */
%put sysdate9: &sysdate9; /* 18SEP2017 */
%put sysday: &sysday; /* Monday */
%put systime: &systime; /* 06:39 */
Note: these variables record the time when the session was started. They then don't change anymore. The actual current time must be deteremined with time()
%put Time when session started: &systime;
%put Actual time %sysfunc(putn(%sysfunc(time()),time.));
Last dataset created
The name of the last
data set is stored in
&syslast
:
data;
txt = 'demonstration of syslast';
run;
%put last dataset created is &syslast;
proc sql;
select * from &syslast;
quit;
Related to the host
%put _sashostname: &_sashostname;
%put _sasservername: &_sasservername;
%put syshostname: &syshostname;
%put systcpiphostname: &systcpiphostname;
%put sysncpu: &sysncpu;
&sysncpu
exposes the value of the option
cpucount .
Memory structure sizes
%put char width: &syscharwidth;
%put bits per address: &sysaddrbits;
%put size of long: &syssizeoflong;
%put size of pointer: &syssizeofptr;
%put size of unicode: &syssizeofunicode;
Related to processess
%put sysprocessid = &sysprocessid;
%put sysprocessname = &sysprocessname;
%put sysprocname = &sysprocname;
Enterprise Guide
%put Client application name: &_clientapp;
%put Client machine name: &_clientmachine;
%put Project name: &_clientprojectname;
%put Project path: &_clientprojectpath;
%put Task filter: &_clienttaskfilter;
%put Task label: &_clienttasklabel;
%put User id of client: &_clientuserid;
%put Username of client: &_clientusername;
%put EG version: &_clientversion;
%put SAS host: &_sashostname;
%put SAS program being run: &_sasprogramfile;
%put SAS server: &_sasservername;
Show all(?) automatic macro variables
Here's a list of some automatic variables:
%macro p(id);
* put "&id = " &&&id;
%put "&id = " &&&id;
%mend p;
DATA _null_;
%p(_CLIENTAPP);
%p(_CLIENTMACHINE);
%p(_CLIENTPROJECTNAME);
%p(_CLIENTPROJECTPATH);
%p(_CLIENTTASKFILTER);
%p(_CLIENTTASKLABEL);
%p(_CLIENTUSERID);
%p(_CLIENTUSERNAME);
%p(_SASHOSTNAME);
%p(_SASPROGRAMFILE);
%p(_SASSERVERNAME);
%p(SYSADDRBITS);
%p(SYSBUFFR);
%p(SYSCC);
%p(SYSCHARWIDTH);
%p(SYSCMD);
%p(SYSDATE);
%P(SYSDATE9);
%p(SYSDAY);
%p(SYSDEVIC);
%p(SYSDMG);
%p(SYSDSN);
%p(SYSENCODING);
%p(SYSENDIAN);
%p(SYSENV);
%p(SYSERR);
%p(SYSERRORTEXT);
%p(SYSFILRC);
%p(SYSHOSTNAME);
%p(SYSINDEX);
%p(SYSINFO);
%p(SYSJOBID); /* The PID (process identifier) of the unix process */
%p(SYSLAST);
%p(SYSLCKRC);
%p(SYSLIBRC);
%p(SYSLOGAPPLNAME);
%p(SYSMACRONAME);
%p(SYSMENV);
%p(SYSMSG);
%p(SYSNCPU);
%p(SYSNOBS);
%p(SYSODSESCAPECHAR);
%p(SYSODSPATH);
%p(SYSPARM);
%p(SYSPBUFF);
%p(SYSPROCESSID);
%p(SYSPROCESSNAME);
%p(SYSPROCNAME);
%p(SYSRC);
%p(SYSSCP);
%p(SYSSCPL);
%p(SYSSITE);
%p(SYSSIZEOFLONG);
%p(SYSSIZEOFPTR);
%p(SYSSIZEOFUNICODE);
%p(SYSSTARTID);
%p(SYSSTARTNAME);
%p(SYSTCPIPHOSTNAME);
%p(SYSTIME);
%p(SYSUSERID);
%p(SYSVER);
%p(SYSVLONG);
%p(SYSVLONG4);
%p(SYSWARNINGTEXT);
run;
_SASWS_
In SAS Studio, &_SASWS_
references the home directory.