Formatting Prompt Values and Generating Macro Variables from Prompts |
Macro Variable Generation and Assignment |
One or more global macro variables is automatically generated for each prompt when the prompt is executed at run time. The values that are specified for the prompts at run time are assigned to the generated macro variables.
One or more macro variables can be generated from both single-value prompts and multi-value prompts. A prompt can have single or multiple values, depending on what you select for the Number of values field on the Prompt Type and Values tab in the New Prompt or Edit Prompt dialog box in SAS Management Console. The following list describes the macro variables that can be generated. PROMPT-NAME is used to represent the name of the prompt.
A base macro variable is generated for every type of prompt except range prompts. The name of the prompt is used as the name of the base macro variable.
Note: Macro variable names can be no more than 32 characters long. Ensure that you consider this restriction when you name the prompt.
For all multi-value prompts, the following macro variables are generated. Suffixes such as _COUNT or a numeric value are appended to the prompt name to create unique names for these macro variables.
The value of this macro variable is the number of values that are specified for the prompt. If no value is specified for a multi-value prompt, then PROMPT-NAME_COUNT is set to 0.
The value of this macro variable is the same as the value of PROMPT-NAME_COUNT. If no value or only one value is specified for a multi-value prompt, then this macro variable is not generated.
When a multi-value prompt has more than one value specified for it, then each value is stored in a macro variable with the name PROMPT-NAMEn where n is the ordinal number of the value in the list of prompt values. The value of PROMPT-NAME1 is the same as the value of the base macro variable. If only one value is specified for a multi-value prompt, then no PROMPT-NAMEn macro variables are generated.
Note: Macro variable names can be no more than 32 characters long. Ensure that you consider this restriction and the length of the suffix when you name the prompt. The length of the suffix is included as part of the 32 characters.
If any of the following special values are specified for a prompt, then the corresponding base macro variable or PROMPT-NAMEn macro variable is assigned a value as follows:
Special Value | Macro Variable Value |
---|---|
(all possible values) |
_ALL_VALUES_ |
(missing values) for numeric, date, time, and timestamp prompts |
. |
(missing values) for character prompts | [space] |
Additional macro variables are generated for certain types of prompts (see the Quick Reference for a list of these macro variables). Suffixes such as _REL, _MIN, and _MAX are appended to the prompt name to create unique names for these macro variables. The following list describes the macro-variables that can be generated. SUFFIX is used to represent the various suffixes.
This macro variable is generated for both single-value and multi-value prompts.
These macro variables are generated when a multi-value prompt has more than one value specified for it. The n is the ordinal number of the value in the list of prompt values. The value of PROMPT-NAME_SUFFIX1 is the same as the value of PROMPT-NAME_SUFFIX. If only one value is specified for a multi-value prompt, then no PROMPT-NAME_SUFFIXn macro variables are generated.
Note: Macro variable names can be no more than 32 characters long. Ensure that you consider this restriction and the length of the suffix when you name the prompt. The length of the suffix is included as part of the 32 characters.
If no value is specified for a prompt, then an empty base macro variable is generated. For range prompts, which do not have base macro variables, the PROMPT-NAME_MIN and PROMPT-NAME_MAX macro variables are empty.
Example: Single Macro Variable Generation |
The following example shows the macro variable that is generated for a single-value text prompt.
Prompt Name | Prompt Value | Macro Variable Name | Macro Variable Value |
---|---|---|---|
MYPROMPT |
Hello World! |
MYPROMPT |
Hello World! |
Examples: Multiple Macro Variable Generation |
The following example shows the macro variables that are generated for a single-value time prompt.
Prompt Name | Prompt Value | Macro Variable Name | Macro Variable Value |
---|---|---|---|
MYTIME |
09:59:55 AM |
MYTIME |
9:59:55 |
MYTIME_LABEL |
9:59:55 AM |
In the preceding example, two macro variables were generated for the single prompt value. If the prompt value had been a relative time value (such as Yesterday), then a third macro variable named MYTIME_REL would have been generated.
The following example shows the macro variables that are generated for a multi-value text prompt.
Prompt Name | Prompt Value | Macro Variable Name | Macro Variable Value |
---|---|---|---|
RESPONSE |
Yes
No
Undecided
(missing
values) |
RESPONSE |
Yes |
RESPONSE_COUNT |
4 |
||
RESPONSE0 |
4 |
||
RESPONSE1 |
Yes |
||
RESPONSE2 |
No |
||
RESPONSE3 |
Undecided |
||
RESPONSE4 |
|
In the preceding example, seven macro variables were generated for the four prompt values. The macro variables RESPONSE and RESPONSE1 both contain the first prompt value. The macro variables RESPONSE_COUNT and RESPONSE0 both contain the number of values that were specified for the prompt. The macro variables RESPONSE2 and RESPONSE3 contain the second and third prompt values, respectively. RESPONSE4 contains a single blank space, which represents the special value (missing values).
The following example shows the macro variables that are generated for a multi-value date prompt.
Prompt Name | Prompt Value | Macro Variable Name | Macro Variable Value |
---|---|---|---|
MYDATE |
Today
Tomorrow
September 04,
2008 |
MYDATE_COUNT |
3 |
MYDATE0 |
3 |
||
MYDATE |
02Sep2008 |
||
MYDATE1 |
02Sep2008 |
||
MYDATE2 |
03Sep2008 |
||
MYDATE3 |
04Sep2008 |
||
MYDATE_LABEL |
Today |
||
MYDATE_LABEL1 |
Today |
||
MYDATE_LABEL2 |
Tomorrow |
||
MYDATE_LABEL3 |
September 04, 2008 |
||
MYDATE_REL |
D0D |
||
MYDATE_REL1 |
D0D |
||
MYDATE_REL2 |
D1D |
In the preceding example, 13 macro variables were generated for the three prompt values.
The macro variables MYDATE_COUNT and MYDATE0 contain the number of values that were specified for the prompt.
The macro variables MYDATE and MYDATE1 both contain the specific date that the first relative date (Today) resolves to. The macro variable MYDATE2 contains the specific date that the second relative date (Tomorrow) resolves to. The macro variable MYDATE3 contains the third prompt value.
The macro variables MYDATE_LABEL, MYDATE_LABEL1, and MYDATE_LABEL2 contain the relative dates that were specified for the prompt. MYDATE_LABEL3 contains the long form of the specific date that was selected for the prompt.
The macro variables MYDATE_REL and MYDATE_REL1 contain the internal representation of Today. The macro variables MYDATE_REL2 contains the internal representation of Tomorrow.
Quick Reference |
The following table lists, by prompt type, the macro variables that are generated and how their values are determined. Examples of the generated macro variables are also provided.
Note: If your application or software feature enables you to create custom types of prompts, then the application or software feature determines which macro variables are generated for those prompts. For information about macro variables for custom types of prompts, see the documentation for your application or software feature.
Prompt Type | Macro Variable | Prompt Value | Macro Variable Name | Macro Variable Values |
---|---|---|---|---|
Text | The PROMPT-NAME macro variable contains the value of the prompt. No additional macro variables are generated for single-value prompts. For more information about the macro variables that are generated for multi-value prompts, see Macro Variable Generation and Assignment. |
Hello World! |
MYPROMPT |
Hello World! |
Numeric | The PROMPT-NAME macro variable contains the value of the prompt. No additional macro variables are generated for single-value prompts. For more information about the macro variables that are generated for multi-value prompts, see Macro Variable Generation and Assignment. |
12 |
MYPROMPT |
12 |
Text range, Numeric range | A base macro variable is not generated for range prompts. |
|
|
|
The PROMPT-NAME_MIN macro variable contains the lower boundary of the specified prompt range. |
From: 23
To: 45 |
MYPROMPT_MIN |
23 |
|
The PROMPT-NAME_MAX macro variable contains the upper boundary of the specified prompt range. |
From: 23
To: 45 |
MYPROMPT_MAX |
45 |
|
Date (Day) |
The PROMPT-NAME macro variable contains the value of the
prompt in the format ddmmmyyyy.1
Here is an explanation of the syntax:
For more information about the macro variables that are generated for multi-value prompts, see Macro Variable Generation and Assignment. |
April 04, 2008 |
MYPROMPT |
04Apr2008 |
The PROMPT-NAME_LABEL macro variable contains one or more
of the following values:
Here is an explanation of the syntax:
For the macro variables that are generated for multi-value prompts, see Macro Variable Generation and Assignment. |
April 04, 2008 |
MYPROMPT_LABEL |
April 04, 2008 |
|
The PROMPT-NAME_REL macro variable contains the internal
representation of the relative date
that is specified for the prompt. This macro variable is generated only when
the prompt value is a relative date.
For more information about the macro variables that are generated for multi-value prompts, see Macro Variable Generation and Assignment. |
Current day of last year |
MYPROMPT_REL |
D0D-1Y |
|
Date (Week, Month, Quarter, Year) |
The PROMPT-NAME macro variable contains the first day of
the week, month, quarter, or year2
that is specified for the prompt. The format of the macro variable value is ddmmmyyyy.1
Here is an explanation of the syntax:
For more information about the macro variables that are generated for multi-value prompts, see Macro Variable Generation and Assignment. |
Week 36 2008 |
MYPROMPT |
01Sep2008 |
The PROMPT-NAME_END macro variable contains the last day
of the week, month, quarter, or year2
that is specified for the prompt. See the above base macro variable entry
for the format that is used.1
For more information about the macro variables that are generated for multi-value prompts, see Macro Variable Generation and Assignment. |
Week 36 2008 |
MYPROMPT_END |
07Sep2008 |
|
The PROMPT-NAME_LABEL macro variable contains one or more
of the following week, month, quarter, or year2
values:
Here is an explanation of the syntax:
For the macro variables that are generated for multi-value prompts, see Macro Variable Generation and Assignment. |
Week 36 2008 |
MYPROMPT_LABEL |
Week 36 2008 |
|
The PROMPT-NAME_REL macro variable contains the internal
representation of the relative date
that is specified for the prompt. This macro variable is generated only when
the prompt value is a relative date.
For more information about the macro variables that are generated for multi-value prompts, see Macro Variable Generation and Assignment. |
Current week of last year |
MYPROMPT_REL |
W0W-1Y |
|
Date range (Day) | A base macro variable is not generated for range prompts. |
|
|
|
The PROMPT-NAME_MIN macro variable contains the lower boundary of the specified prompt range. See the base macro variable entry for date prompts for the format that is used.1 |
From: August 31, 2008
To: September 06, 2008 |
MYPROMPT_MIN |
31Aug2008 |
|
The PROMPT-NAME_MAX macro variable contains the upper boundary of the specified prompt range. See the base macro variable entry for date prompts for the format that is used.1 |
From: August 31, 2008
To: September 06, 2008 |
MYPROMPT_MAX |
06Sep2008 |
|
The PROMPT-NAME_MIN_LABEL macro variable contains the lower boundary of the specified prompt range in the format that is specified for the PROMPT-NAME_LABEL macro variable entry for date (day) prompts. |
From: August 31, 2008
To: September 06, 2008 |
MYPROMPT_MIN_LABEL |
August 31, 2008 |
|
The PROMPT-NAME_MAX_LABEL macro variable contains the upper boundary of the specified prompt range in the format that is specified for the PROMPT-NAME_LABEL macro variable entry for date (day) prompts. |
From: August 31, 2008
To: September 06, 2008 |
MYPROMPT_MAX_LABEL |
September 06, 2008 |
|
The PROMPT-NAME_MIN_REL macro variable contains the internal representation of the relative date that is specified for the lower boundary. This macro variable is generated only when the prompt value is a relative date. |
From: Today To: Current day of next month |
MYPROMPT_MIN_REL |
D0D |
|
The PROMPT-NAME_MAX_REL macro variable contains the internal representation of the relative date that is specified for the upper boundary. This macro variable is generated only when the prompt value is a relative date. |
From: Today
To: Current day of next month |
MYPROMPT_MAX_REL |
DOD1M |
|
Date range (Week, Month, Quarter, Year) | A base macro variable is not generated for range prompts. |
|
|
|
The PROMPT-NAME_MIN macro variable contains the first day of the lower boundary of the specified prompt range. See the base macro variable entry for date prompts for the format that is used.1 |
From: September 2008
To: June 2009 |
MYPROMPT_MIN |
01Sep2008 |
|
The PROMPT-NAME_MAX macro variable contains the first day of the upper boundary of the specified prompt range. See the base macro variable entry for date prompts for the format that is used.1 |
From: September 2008
To: June 2009 |
MYPROMPT_MAX |
01Jun2009 |
|
The PROMPT-NAME_MIN_LABEL macro variable contains the lower boundary of the specified prompt range in the formats that are specified for the PROMPT-NAME_LABEL macro variable entry for date (week, month, quarter, year) prompts. |
From: September 2008
To: June 2009 |
MYPROMPT_MIN_LABEL |
September 2008 |
|
The PROMPT-NAME_MAX_LABEL macro variable contains the upper boundary of the specified prompt range in the formats that are specified for the PROMPT-NAME_LABEL macro variable entry for date (week, month, quarter, year) prompts. |
From: September 2008
To: June 2009 |
MYPROMPT_MAX_LABEL |
June 2009 |
|
The PROMPT-NAME_MIN_END macro variable contains the last day of the lower boundary of the specified prompt range . See the base macro variable entry for date prompts for the format that is used.1 |
From: September 2008
To: June 2009 |
MYPROMPT_MIN_END |
30Sep2008 |
|
The PROMPT-NAME_MAX_END macro variable contains the last day of the upper boundary of the specified prompt range. See the base macro variable entry for date prompts for the format that is used.1 |
From: September 2008
To: June 2009 |
MYPROMPT_MAX_END |
30Jun2009 |
|
The PROMPT-NAME_MIN_REL macro variable contains the internal representation of the relative date that is specified for the lower boundary. This macro variable is generated only when the prompt value is a relative date. |
From: Current week
To: Current week of next year |
MYPROMPT_MIN_REL |
W0W |
|
The PROMPT-NAME_MAX_REL macro variable contains the internal representation of the relative date that is specified for the upper boundary. This macro variable is generated only when the prompt value is a relative date. |
From: Current week
To: Current week of next year |
MYPROMPT_MAX_REL |
W0W1Y |
|
Time |
The PROMPT-NAME macro variable contains the value of the
prompt in the format hh:mm:ss.1
Here is an explanation of the syntax:
|
02:05:28 PM |
MYPROMPT |
14:05:28 |
|
The PROMPT-NAME_LABEL macro variable contains one of the
following values:
Here is an explanation of the syntax:
|
02:05:28 PM |
MYPROMPT_LABEL |
02:05:28 PM |
|
The PROMPT-NAME_REL macro variable contains the internal representation of the relative time that is specified for the prompt. This macro variable is generated only when the prompt value is a relative time (such as Next minute). |
Next minute |
MYPROMPT_REL |
m1m |
Timestamp |
The PROMPT-NAME macro variable contains the value of the
prompt in the format ddmmmyyyyhh:mm:ss.1
Here is an explanation of the syntax:
|
September 02, 2008 02:07:03 PM |
MYPROMPT |
02Sep2008 14:07:03 |
|
The PROMPT-NAME_LABEL macro variable contains one of the
following values:
Here is an explanation of the syntax:
|
September 02, 2008 02:07:03 PM |
MYPROMPT_LABEL |
September 02, 2008 02:07:03 PM |
|
The PROMPT-NAME_REL macro variable contains the internal representation of the relative timestamp that is specified for the prompt. This macro variable is generated only when the prompt value is a relative timestamp (such as Current date and time). |
Current date and time |
MYPROMPT_REL |
T0m |
Time range, Timestamp range | A base macro variable is not generated for range prompts. |
|
|
|
The PROMPT-NAME_MIN macro variable contains the lower boundary of the specified prompt range. See the base macro variable entries for time and timestamp prompts for the formats that are used.1 |
From: 01:13:04 AM
To: 02:13:14 PM |
MYPROMPT_MIN |
1:13:04 |
|
The PROMPT-NAME_MAX macro variable contains the upper boundary of the specified prompt range. See the base macro variable entries for time and timestamp prompts for the formats that are used.1 |
From: 01:13:04 AM
To: 02:13:14 PM |
MYPROMPT_MAX |
14:13:14 |
|
The PROMPT-NAME_MIN_LABEL macro variable contains the lower boundary of the specified prompt range in the formats that are specified for the PROMPT-NAME_LABEL macro variables for time and timestamp prompts.1 |
From: October 29, 2008 10:12:12 AM
To: February 14, 2009 12:25:36 PM |
MYPROMPT_MIN_LABEL |
October 29, 2008 10:12:12 AM |
|
The PROMPT-NAME_MAX_LABEL macro variable contains the lower boundary of the specified prompt range in the formats that are specified for the PROMPT-NAME_LABEL macro variables for time and timestamp prompts.1 |
From: October 29, 2008 10:12:12 AM
To: February 14, 2009 12:25:36 PM |
MYPROMPT_MAX_LABEL |
February 14, 2009 12:25:36 PM |
|
The PROMPT-NAME_MIN_REL macro variable contains the internal representation of the relative time or timestamp that is specified for the lower boundary. This macro variable is generated only when the lower boundary is a relative time or timestamp (such as Beginning of next hour). |
From: Beginning of next hour To: End of next hour |
MYPROMPT_MIN_REL |
t1HBH (for time)
T1HBH (for timestamp) |
|
The PROMPT-NAME_MAX_REL macro variable contains the internal representation of the relative time or timestamp that is specified for the upper boundary. This macro variable is generated only when the upper boundary is a relative time or timestamp (such as End of next hour). |
From: Beginning of next hour
To: End of next hour |
MYPROMPT_MAX_REL |
t1HEH (for time)
T1HEH (for timestamp) |
|
Color |
The PROMPT-NAME macro variable contains the value of the
prompt in the format cxrrggbb.
Here is an explanation of the syntax:
|
CXFF0000 (bright red) | MYPROMPT |
cxff0000 |
Data source |
The PROMPT-NAME macro variable contains the value of the
prompt in the format /folder-name-1/<.../folder-name-n/>data-source-name(type).
Here is an explanation of the syntax:
|
/Shared Data/Tables/MYDATA(Table) |
MYPROMPT |
/Shared Data/Tables/MYDATA(Table) |
PROMPT-NAME_TYPE contains the type of the data source,
represented by the following numbers:
|
/Shared Data/Tables/MYDATA(Table) |
MYPROMPT_TYPE |
1 |
|
File or directory |
The PROMPT-NAME macro variable contains the value of the
prompt in the format directory-specification<filename>
Here is an explanation of the syntax:
|
C:\Documents and Settings\All Users\Documents\myfile.txt |
MYPROMPT |
C:\Documents and Settings\All Users\Documents\myfile.txt |
The PROMPT-NAME_SERVER macro variable contains the name of the SAS server that was specified for the prompt. |
C:\Documents and Settings\All Users\Documents\myfile.txt |
MYPROMPT_SERVER |
SASApp - Logical Workspace Server |
|
Data library | The PROMPT-NAME macro variable contains the libref of the library that is specified for the prompt. |
/Shared Data/Libraries/SASHELP(Library) |
MYPROMPT |
SASHELP |
The PROMPT-NAME_PATH macro variable contains the name and location of the library. The format of the macro variable value is /folder-name-1/<.../folder-name-n/>library-name(Library). |
/Shared Data/Libraries/SASHELP(Library) |
MYPROMPT_PATH |
/Shared Data/Libraries/SASHELP(Library) |
|
1
Relative date, relative time, and relative timestamp values are resolved
to specific date, time, and timestamp values, respectively, for this macro
variable.
2 All dates are based on the Gregorian calendar. Each year begins with the month of January, and each week begins on Monday and ends on Sunday, regardless of locale. |
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.