programs to check the date before you execute code that you want to run on certain dates
of the month.
Example: Formatting a SYSDATE Value
Macro FDATE assigns a format that you specify to the value of SYSDATE:
%macro fdate(fmt);
%global fdate;
data _null_;
call symput("fdate",left(put("&sysdate"d,&fmt)));
run;
%mend fdate;
%fdate(worddate.)
title "Tests for &fdate";
If you execute this macro on July 28, 1998, SAS sees the statements:
DATA _NULL_;
CALL SYMPUT("FDATE",LEFT(PUT("28JUL98"D,WORDDATE.)));
RUN;
TITLE "Tests for July 28, 1998";
For another method of formatting the current date, see the %SYSFUNC and
%QSYSFUNC functions.
SYSDATE9 Automatic Macro Variable
Contains the date on which a SAS job or session began executing.
Type: Automatic macro variable (read only)
See: “SYSDATE Automatic Macro Variable” on page 202
Details
SYSDATE9 contains a SAS date value in the DATE9. format, which displays a two-digit
date, the first three letters of the month name, and a four-digit year. The date does not
change during the individual job or session. For example, you could use SYSDATE9 in
programs to check the date before you execute code that you want to run on certain dates
of the month.
Example: Formatting a SYSDATE9 Value
Macro FDATE assigns a format that you specify to the value of SYSDATE9:
%macro fdate(fmt);
b %global fdate;
data _null_;
call symput("fdate",left(put("&sysdate9"d,&fmt)));
run;
%mend fdate;
%fdate(worddate.)
title "Tests for &fdate";
If you execute this macro on July 28, 2008, SAS sees the statements:
SYSDATE9 Automatic Macro Variable 203
DATA _NULL_;
CALL SYMPUT("FDATE",LEFT(PUT("28JUL2008"D,WORDDATE.)));
RUN;
TITLE "Tests for July 28, 2008";
For another method of formatting the current date, see the %SYSFUNC and
%QSYSFUNC functions.
SYSDATE9 Automatic Macro Variable
Contains the date on which a SAS job or session began executing.
Type: Automatic macro variable (read only)
See: “SYSDATE Automatic Macro Variable” on page 202
Details
SYSDATE9 contains a SAS date value in the DATE9. format, which displays a two-digit
date, the first three letters of the month name, and a four-digit year. The date does not
change during the individual job or session. For example, you could use SYSDATE9 in
programs to check the date before you execute code that you want to run on certain dates
of the month.
Example: Formatting a SYSDATE9 Value
Macro FDATE assigns a format that you specify to the value of SYSDATE9:
%macro fdate(fmt);
b %global fdate;
data _null_;
call symput("fdate",left(put("&sysdate9"d,&fmt)));
run;
%mend fdate;
%fdate(worddate.)
title "Tests for &fdate";
If you execute this macro on July 28, 2008, SAS sees the statements:
DATA _NULL_;
CALL SYMPUT("FDATE",LEFT(PUT("28JUL2008"D,WORDDATE.)));
RUN;
TITLE "Tests for July 28, 2008";
For another method of formatting the current date, see the %SYSFUNC and
%QSYSFUNC functions.
SYSDAY Automatic Macro Variable
Contains the day of the week on which a SAS job or session began executing.
Type: Automatic macro variable (read only)
204 Chapter 14 Automatic Macro Variables
Details
You can use SYSDAY to check the current day before executing code that you want to
run on certain days of the week, provided you initialized your SAS session today.
Example: Identifying the Day When a SAS Session
Started
The following statement identifies the day and date on which a SAS session started
running.
%put This SAS session started running on: &sysday, &sysdate9.;
When this statement executes on Wednesday, December 19, 2007 for a SAS session that
began executing on Monday, December 17, 2007, the following line is written to the
SAS log:
This SAS session started running on: Monday, 17DEC2007
SYSDEVIC Automatic Macro Variable
Contains the name of the current graphics device.
Type: Automatic macro variable (read and write)
See: “Automatic Macro Variables in UNIX Environments” in SAS Companion for UNIX
Environments
“Automatic Macro Variables” in SAS Companion for Windows
“Macro Variables” in SAS Companion for z/OS
Details
The current graphics device is the one specified at invocation of SAS. You can specify
the graphics device on the command line in response to a prompt when you use a
product that uses SAS/GRAPH. You can also specify the graphics device in a
configuration file. The name of the current graphics device is also the value of the SAS
system option DEVICE=.
For more information, see the SAS documentation for your operating environment.
Note: The macro processor always stores the value of SYSDEVIC in unquoted form. To
quote the resolved value of SYSDEVIC, use the %SUPERQ macro quoting function.
Comparisons
Assigning a value to SYSDEVIC is the same as specifying a value for the DEVICE=
system option.
SYSDMG Automatic Macro Variable
Contains a return code that reflects an action taken on a damaged data set.
Type: Automatic macro variable (read and write)
SYSDMG Automatic Macro Variable 205
Default: 0
Details
You can use the value of SYSDMG as a condition to determine further action to take.
SYSDMG can contain the following values:
Table 14.2 SYSDMG Values and Descriptions
Value Description
0 No repair of damaged data sets in this session. (Default)
1 One or more automatic repairs of damaged data sets have occurred.
2 One or more user-requested repairs of damaged data sets have occurred.
3 One or more opens failed because the file was damaged.
4 One or more SAS tasks were terminated because of a damaged data set.
5 One or more automatic repairs of damaged data sets have occurred; the last-
repaired data set has index file removed, as requested.
6 One or more user requested repairs have occurred; the last-repaired data set
has index file removed, as requested.
SYSDSN Automatic Macro Variable
Contains the libref and name of the most recently created SAS data set.
Type: Automatic macro variable (read and write)
See: “SYSLAST Automatic Macro Variable” on page 214
Details
The libref and data set name are displayed in two left-aligned fields. If no SAS data set
has been created in the current program, SYSDSN returns eight blanks followed by
_NULL_ followed by two more blanks.
Note: The macro processor always stores the value of SYSDSN in unquoted form. To
quote the resolved value of SYSDSN, use the %SUPERQ macro quoting function.
Comparisons
Assigning a value to SYSDSN is the same as specifying a value for the _LAST_=
system option.
The value of SYSLAST is often more useful than SYSDSN because the value of
SYSLAST is formatted so that you can insert a reference to it directly into SAS code
in place of a data set name.
206 Chapter 14 Automatic Macro Variables
Example: Comparing Values Produced by SYSDSN and
SYSLAST
Create a data set Work.Test and then enter the following statements:
%put Sysdsn produces: *&sysdsn*;
%put Syslast produces: *&syslast*;
When these statements execute, the following lines are written to the SAS log:
Sysdsn produces: *WORK TEST *
Syslast produces: *WORK.TEST *
When the libref or data set name contain fewer than eight characters, SYSDSN
maintains the blanks for the unused characters. SYSDSN does not display a period
between the libref and data set name fields.
SYSENCODING Automatic Macro Variable
Contains the name of the SAS session encoding.
Type: Automatic macro variable (read only)
Details
SYSENCODING displays the name with a maximum length of 12 bytes.
Example: Using SYSENCODING to Display the SAS
Session Encoding
The following statement displays the encoding for the SAS session:
%put The encoding for this SAS session is: &sysencoding;
When this statement executes, the following comment is written to the SAS log:
The encoding for this SAS session is: wlatin1
SYSENDIAN Automatic Macro Variable
Contains an indication of the byte order of the current session. The possible values are LITTLE or BIG.
Type: Automatic macro variable (read only)
Details
The SYSENDIAN automatic macro variable indicates the byte order of the current SAS
session. There are two possible values: LITTLE and BIG.
SYSENDIAN Automatic Macro Variable 207
..................Content has been hidden....................

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