You are here: Administration Riser Bar>Using Macro Variables>Using Macro Variables in Work Tables

DataFlux Data Management Studio 2.6: User Guide

Using Macro Variables in Work Tables

You can use macro variables to get one or more string variables in a process job into default work table input column values. This approach gives you an alternative method to creating a data job that uses the Work Table Reader and Work Table Writer nodes and adding it to the process job. You can simply define macro variables and specify the string variables that you need to access as the default values of the macro variables. Then you can add these macro variables to the Inputs tabs of appropriate nodes in the process job, such as Echo or SAS Code. This simplified process contains the following tasks:

Create Macro Variable Definitions

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 state_name1) and a value (such as North Carolina) for the macro variable, as shown in the following display:

    This setting is equivalent to the following macro variable definition: State_Name=North Carolina.

  3. Click OK to save the macro variable definition. Then create the other macro variable definitions that you need. For example, you could create macro variable definitions for additional states and add variable definitions for the state capitals. The new macro variables are added to the list in the information pane, as shown in the following display:

Add the Macro Variables to a Process Job

Now you can add the macro variables that you have created to a process job. For example, you can create a process job that contains an Echo node and add the macro variables to the Input tab in the node. Perform the following steps:

  1. Open the process job that you need to update. The sample job for this topic is named echo_macro_table.
  2. Open the properties window for a node, such as the Echo node in the sample job.
  3. Click Inputs to access the Inputs tab.
  4. Click New in the toolbar and select New Input Table in the drop-down menu.
  5. Click in the row that you added to the Inputs table and click Edit Default Value.
  6. Click Manage Columns.
  7. Click New Column and enter State in the Column name field.
  8. Click OK to save the column name and repeat the process to add the Capital column name.
  9. Click New Row and enter the following macro variables into State and Capital columns: %%state_name1%% and %%state_capital1%%.
  10. Enter the macro variables for the remaining states and capitals. The default values entries are shown in the following display:

  11. Click OK to save the default values. Then return to the process flow diagram for the process job.

You can use a macro variable to specify a column name or cell value. The macro variable for a column name must resolve to some value. It cannot be null or you will get an error.

Run the Job and Review the Output

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

  1. Run the job.
  2. Click Show Details in the Log tab toolbar.
  3. Click the name of the States table in the Details dialog.
  4. Review the table in the Run Time Values dialog. The table for the sample job is shown in the following display:

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

Doc ID: dfDMStd_Task_Macros_Worktable.html