我是SPSS宏语法的新手,很难根据简单的循环计数器标记变量。这里就是我试图做的:SPSS宏中的变量标签宏
define !make_indicatorvars()
!do !i = 1 !to 10.
!let !indicvar = !concat('indexvar_value_', !i, '_ind')
compute !indicvar = 0.
if(indexvar = !i) !indicvar = 1.
variable labels !indicvar 'Indexvar has value ' + !quote(!i).
value labels !indicvar 0 "No" 1 "Yes".
!doend
!enddefine.
然而,当我运行它,我得到以下警告:
Warning # 207 on line ... in column ... Text: ...
A '+' was found following a text string, indicating continuation, but the next non-blank character was not a quotation mark or an apostrophe.
Warning # 4465 in column ... Text: ...
An invalid symbol appears on the VAR LABELS command where a slash was
expected. All text through the next slash will be be ignored.
事实上,标签则只有“Indexvar具有价值”。
在使用“设置MPRINT上printback”,下面的代码被印:
variable labels indexvar_value_1_ind 'Indexvar has value ' '1'
所以看来SPSS似乎以某种方式删除“+”这是应该来连接两个字符串,但为什么?
宏的其余部分工作正常,它只是变量标签命令导致问题。