最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

string - spss conditional based on macro text - Stack Overflow

programmeradmin6浏览0评论

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.
发布评论

评论列表(0)

  1. 暂无评论