Hello,
I am trying to figure out a way to recode a group of variables where the variables have the same prefix and are sequentially numbered with a suffix, but the total number of variables is dynamic.
For example, I have these variables:
a_1, a_2, a_3 ... a_x
b_1, b_2, b_3 ... b_x
c_1, c_2, c_3... c_x
The total number of a_, b_, and c_ variables are equal. I need to do the following...
recode a_1 to a_x (1=1) (2=0).
recode b_1 to b_x (1=1) (2=0).
recode c_1 to c_x (1=1) (2=0).
The value of x is going to vary depending on the dataset I am running the code on. I want to allow the user to define the value of x before running the syntax.
I know I could have the user do something like this to define a constant, but I'm not sure how I could then reference !x in my recode syntax:
define !x()
229
!enddefine.
Is it possible to somehow concatenate the "a_", "b_", or "c_" with !x in my recode syntax? I know there are ways to do this with python integration, but I am unable to use that at my workplace. Anyone know of any workarounds I could use to accomplish this?
Thanks!
------------------------------
Alexa Bolwin
------------------------------