我是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似乎以某種方式刪除「+」這是應該來連接兩個字符串,但爲什麼?
宏的其餘部分工作正常,它只是變量標籤命令導致問題。