【发布时间】:2017-11-28 23:22:44
【问题描述】:
我有一个我经常使用的 SPSS 语法,其中有几个文本字符串出现在几个地方。是否有一种将字符串分配给变量的方法,以避免在多个位置更改字符串? (类似于 R 中的“X
x <- "repeated string example"
syntax object 1 = X.
...
syntax object n = X.
谢谢!
【问题讨论】:
我有一个我经常使用的 SPSS 语法,其中有几个文本字符串出现在几个地方。是否有一种将字符串分配给变量的方法,以避免在多个位置更改字符串? (类似于 R 中的“X
x <- "repeated string example"
syntax object 1 = X.
...
syntax object n = X.
谢谢!
【问题讨论】:
这是 SPSS 宏语言最简单的用法。例如:
* first you define the macro .
define !MyString () "repeated string example" !enddefine.
define !AnotherString () "ample" !enddefine.
* now you can use it in the syntax as in the following examples.
string SomeStringVar (a30).
compute SomeStringVar = !MyString.
compute MyIndex=char.index(!MyString, !AnotherString).
if someVar=!MyString cond=1.
【讨论】: