combine | Combine the values of two or more variables | combine |
The COMBINE macro combines two or more variables (character or numeric) into a single one. This is useful for situations where you need two or more CLASS variables, but some procedure or macro stupidly only handles one. Also handy for plots of the form
plot y * x = Group Sex
where there are two or more curve variables.
The COMBINE macro is called with keyword parameters. The VAR=
parameter is required.
The arguments may be listed within parentheses in any order, separated
by commas. For example:
%combine(var=group gender, result=gp_sex);
DATA=_LAST_
]
RESULT=_ID_
]
OUT=
data set.
VAR=
is truncated to this length
in RESULT. To specify different truncation lengths, use a list of numbers,
whose order corresponds to the VAR=
variables, e.g.,
ABBREV=2 2 4
.
RESULT=
variable is truncated to this total length,
regardless of the ABBREV=
setting.
USEFMT=0
]
The internally calculated length for the result variable is incorrect for numeric variables.
Should provide a way to use a formatted value of a character variable.
%include macros(combine); *-- or include in an autocall library; data design; do task = 'EASY', 'HARD'; do dose = ., 0 to 2; output; end; end; %combine(data=design, var=task dose, out=test); proc print;
Obs task dose _id_ 1 EASY . EASY:. 2 EASY 0 EASY:0 3 EASY 1 EASY:1 4 EASY 2 EASY:2 5 HARD . HARD:. 6 HARD 0 HARD:0 7 HARD 1 HARD:1 8 HARD 2 HARD:2