由于问卷收集回来的不少问题都是分散的二分变量,我希望合并成一个新变量。原有代码如下:
/*个人年龄.
if (V_4=1) Age=15.
if (V_5=1) Age=16.
if (V_6=1) Age=17.
if (V_7=1) Age=18.
if (V_8=1) Age=19.
if (V_9=1) Age=20.
if (V_10=1) Age=21.
if (V_11=1) Age=22.
if (V_12=1) Age=23.
if (V_13=1) Age=24.
if (V_14=1) Age=25.
if (V_15=1) Age=26.
if (V_16=1) Age=27.
if (V_17=1) Age=28.
if (V_18=1) Age=29.
if (V_19=1) Age=30.
excecute.
这样就新生成年龄变量,表示15到30岁的人。
我希望用宏语句来简化变量,以免变量太多的时候写起来头疼。
写出下面的语句后,发现出错不能运行。希望高手指点,不甚感激!
DEFINE VAR_N ( varbeg= !charend('/')
/varend= !charend('/')
/arg1= !tokens(1)
/arg2= !tokens(1)
/begin= !tokens(1))
!do !i=!arg1 !to !arg2.
if (!concat(!varbeg,!i)=1)) !varend=(!begin+!i-!arg1)
!doend
!enddefine.
VAR_N varbeg=V_ varend=ageX arg1=4 arg2=19.