You are here: Administration Riser Bar>Using Macro Variables>Using Macro Variables to Specify File Names

DataFlux Data Management Studio 2.6: User Guide

Using Macro Variables to Specify File Names

Overview

Macro variables are often used instead of hard-coded file names so that jobs, profiles, and other objects are portable across environments. They can also be used to change a job's output without updating the job. For example, in the following data job, the Text Input 1 node reads a delimited text file that is specified with a hard-coded path name, such as C:\sources_external\delim_com.dat. Similarly, the Text Output 1 node writes output to a delimited text file that is specified with a hard-coded path name.

You could replace the hard-coded path name in Text Input 1 node with a macro variable, such as %%DELIM_INPUT%%, as shown in the next display.

The macro variable would be replaced at run-time with the file path that is specified in the definition for the macro variable. By changing the file that is specified in the macro variable definition, you could change the output of the job without updating the job.

In order to focus on how macro variables are created and how they can be used to specify file names, assume that the job flow above has been created, and that only the following tasks remain:

Create the Macro Variable Definition

The easiest way to add a macro variable definition is to use the Macro Files folder in the Administration riser. Macro variable definitions added here are stored in the macros.cfg file in your user profile directory by default. Perform the following steps:

  1. On the Administration riser, open the Macro Files folder and right-click the macros item. Then, click New Macro in the information pane at right to display the New Macro dialog.
  2. Enter a name (such as DELIM_INPUT) and a value (such as C:\sources_external\delim_com.dat) for the macro variable. This is equivalent to the following macro variable definition: DELIM_INPUT=C:\sources_external\delim_com.dat
  3. Click OK to save the macro variable definition. The new macro variable is added to the list in the information pane.

Use the Macro in the Job

Perform the following steps to use a macro in a data job:

  1. Open the properties dialog for the node that will reference the macro. In the current example, this would be the Text File Input 1 node.
  2. Replace the explicit path to the input with the macro variable that you just defined. Be sure to enclose the variable name in the %% characters, as shown in the following display:

  3. Click OK to save the setting.
  4. Right-click the Text File Input node. The dialog in the following display is shown:

    Click Open advanced dialog to see the properties shown in the following display:

    Note that the macro variable is populated for the Filename property.

Run the Job and Review the Output

You can confirm the macro variable worked by running the job. Perform the following steps:

  1. Run the job. The log confirms that the macro variable resolved successfully and supplied the requested input file. The following display shows the data in the specified output file:

Documentation Feedback: yourturn@sas.com
Note: Always include the Doc ID when providing documentation feedback.

Doc ID: dfU_T_Macros_InJobs.html