string - spss conditional based on macro text - Stack Overflow

I'm trying to build a simple variable in spss like below but can't figure it out from documen

I'm trying to build a simple variable in spss like below but can't figure it out from documentation. In sas, you simply need to put qoutes around your macro to resolve. Can't figure out how in SPSS.

define !reg (name= !tokens(1)).

compute !concat(!name,'_f') = 0.

if type =("!name")  compute !concat(!name,'_f') = 1.

execute.

!enddefine. 

!reg name=joe.

I'm trying to build a simple variable in spss like below but can't figure it out from documentation. In sas, you simply need to put qoutes around your macro to resolve. Can't figure out how in SPSS.

define !reg (name= !tokens(1)).

compute !concat(!name,'_f') = 0.

if type =("!name")  compute !concat(!name,'_f') = 1.

execute.

!enddefine. 

!reg name=joe.
Share Improve this question asked Mar 25 at 19:51 Mark HedmanMark Hedman 232 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

OK so you want the value of !name to be in quotes in the resulting syntax, but putting the quotes there in type =("!name") disrupts the macro. So the solution is

!quote(!name)

Now I'm not sure what you are doing with the macro here, but I suggest a couple of corrections to the full line of code - no need for parentheses around the quote, no need for compute after the if:

if type = !quote(!name) !concat(!name,'_f') = 1.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744172262a4561590.html

相关推荐

  • string - spss conditional based on macro text - Stack Overflow

    I'm trying to build a simple variable in spss like below but can't figure it out from documen

    9天前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信