【问题标题】:Is there a way to assign a variable in SPSS (x <- "string value") for use in multible syntax locations?有没有办法在 SPSS (x <- "string value") 中分配一个变量以用于多语法位置?
【发布时间】:2017-11-28 23:22:44
【问题描述】:

我有一个我经常使用的 SPSS 语法,其中有几个文本字符串出现在几个地方。是否有一种将字符串分配给变量的方法,以避免在多个位置更改字符串? (类似于 R 中的“X

x <- "repeated string example"
syntax object 1 = X.
...
syntax object n = X.

谢谢!

【问题讨论】:

    标签: variables syntax spss


    【解决方案1】:

    这是 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.
    

    【讨论】:

      猜你喜欢
      • 2013-05-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多