Conditional macro - substitute different variable name

Moderators: statman, Analyst Techy, andris, Fierce, GerineL, Smash

0101
Posts: 52
Joined: Fri Mar 04, 2011 9:42 pm

Conditional macro - substitute different variable name

Postby 0101 » Sat Jun 29, 2013 5:07 am

I have spent a while trying to figure this out. It seems it should be easy.

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, this is how I envision it, but it seems you can't put macros in a DO IF.

Code: Select all

*********************
* 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. 
Any ideas?

Who is online

Users browsing this forum: No registered users and 3 guests

cron