Previous Page | Next Page

Formatting Prompt Values and Generating Macro Variables from Prompts

Macro Variables That Are Generated 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.


Example: Single Macro Variable Generation

The following example shows the macro variable that is generated for a single-value text prompt.

Generated Macro Variables 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.

Generated Macro Variables 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.

Generated Macro Variables 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.

Generated Macro Variables 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.


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.  [cautionend]

Generated Macro Variables by Prompt Type for Prompt MYPROMPT
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:

dd

specifies a two-digit integer that represents the day of the month.

mmm

specifies the first three letters of the month.

yyyy

specifies a four-digit integer that represents the year.

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:
  • for the relative date values, the relative date (for example, Tomorrow.

  • for specific date values, the date in the format month-namedd, yyyy.

Here is an explanation of the syntax:

month-name

specifies the full name of the month.

dd

specifies a two-digit integer that represents the day of the month.

yyyy

specifies a four-digit integer that represents the year.

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:

dd

specifies a two-digit integer that represents the day of the month.

mmm

specifies the first three letters of the month.

yyyy

specifies a four-digit integer that represents the year.

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:
  • for the relative date values, the relative date (for example, Current week.

  • for specific date values, the date in the following formats:

    • Week wwyyyy

    • month-nameyyyy

    • quarter-name quarter yyyy

    • yyyy

Here is an explanation of the syntax:

ww

specifies a two-digit integer that represents the week of the year.

month-name

specifies the full name of the month.

quarter-name

specifies the quarter of the year (1st, 2nd, 3rd, or 4th).

yyyy

specifies a four-digit integer that represents the year.

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:

hh

specifies a one-digit or two-digit integer that represents the hour of a 24-hour day.

mm

specifies a two-digit integer that represents the minute of the hour.

ss

specifies a two-digit integer that represents the second of the minute.

02:05:28 PM
MYPROMPT 14:05:28

The PROMPT-NAME_LABEL macro variable contains one of the following values:
  • for relative time values, the relative time (for example, Current time).

  • for specific time values, the time in the format hh:mm:ssAM | PM.

Here is an explanation of the syntax:

hh

specifies a two-digit integer that represents the hour of a 12-hour day.

mm

specifies a two-digit integer that represents the minute of the hour.

ss

specifies a two-digit integer that represents the second of the minute.

AM or PM

specifies either the time period 00:01-12:00 noon (AM) or the time period 12:01-12:00 midnight (PM).

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:

dd

specifies a two-digit integer that represents the day of the month.

mmm

specifies the first three letters of the month.

yyyy

specifies a four-digit integer that represents the year.

hh

specifies a one-digit or two-digit integer that represents the hour of a 24-hour day.

mm

specifies a two-digit integer that represents the minute of the hour.

ss

specifies a two-digit integer that represents the second of the minute.

September 02, 2008 02:07:03 PM
MYPROMPT 02Sep2008 14:07:03

The PROMPT-NAME_LABEL macro variable contains one of the following values:
  • for relative timestamp values, the relative timestamp (for example, Current date and time).

  • for specific time values, the time in the format month-namedd, yyyyhh:mm:ss AM | PM.

Here is an explanation of the syntax:

month-name

specifies the full name of the month.

dd

specifies a two-digit integer that represents the day of the month.

yyyy

specifies a four-digit integer that represents the year.

hh

specifies a two-digit integer that represents the hour of a 12-hour day.

mm

specifies a two-digit integer that represents the minute of the hour.

ss

specifies a two-digit integer that represents the second of the minute.

AM or PM

specifies either the time period 00:01-12:00 noon (AM) or the time period 12:01-12:00 midnight (PM).

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:

rr

specifies the red component.

gg

specifies the green component.

bb

specifies the blue component.

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:

/folder-name-1/<.../folder-name-n/>

specifies the location of the data source.

data-source-name

specifies the name of the data source.

type

specifies the type of data source (Table, InformationMap, or Cube).

/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:
  • 1 represents a table

  • 2 represents a cube

  • 4 represents a relational information map

  • 8 represents an OLAP information map

/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:

directory-specification

specifies the location of the file or directory in the file system of the SAS Workspace Server that was specified for the prompt.

filename

specifies the name of the file. This value is available only if the prompt is a file prompt.

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.

Previous Page | Next Page | Top of Page