有没有办法在 SPSS (x <- "string value") 中分配变量以用于多个语法位置?
Is there a way to assign a variable in SPSS (x <- "string value") for use in multible syntax locations?
我有一个我经常使用的 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.
我有一个我经常使用的 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.