# Conditional macro - substitute variable name depending on condition

#### grreee12

##### New Member
I would like to be able to specify the dataset I'm working with e.g., (compute DataSet = 1), and then conditionally define some macros based on the specified DataSet. Then I can run a bunch of syntax and have it use the appropriate macro definitions.

For example, below is how I envision it, but it seems you can't put macros in a DO IF.

Pretend that Dataset 1 uses the variable name "Gender" for the male/female question, whereas Dataset 2 uses the variable name "Sex." A lot of analysis is based on male/female, so rather than duplicate most of it, I'd like to write it once and use the the variable "Gender" or "Sex" depending on the dataset being used.

Code:
*********************
* Specify the dataset
* 1 = the ABC dataset
* 2 = the XYZ dataset.

compute DataSet = 1.
*********************

DO IF DataSet = 1.
define !BoyGirl() Gender !enddefine.
ELSEIF DataSet = 2.
define !BoyGirl() Sex !enddefine.
END IF.

frequencies variables = !BoyGirl.

CROSSTABS
/TABLES=Race BY !BoyGirl
/FORMAT=AVALUE TABLES
/CELLS=COUNT
/COUNT ROUND CELL.

etc.