1

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.

1 Answer 1

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.
Sign up to request clarification or add additional context in comments.

2 Comments

I'm trying to build a simply binary using a macro call. I'd like to first create a variable called joe_f = 0. Then using a macro do something like this :
Thanks, the !quote addition achieved what I wanted, the new syntax is : define !reg (name= !tokens(1)). compute !concat(!name,'_f') = 0. if (name=!quote(!name)) !concat(!name,'_f') = 1. execute. !enddefine. !reg name=joe.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.