admin管理员组

文章数量:1410730

been programming in SAS for 14 year and just jumped into SPSS.

In SAS you can combine a macro call and a text string very easily using a period.

i.e.

%let name = ted ;

data work1 ;
var = &name._is_fun ;
run ;

var would resolve to ted_is_fun

I cannot for the life of me figure out how to do this simply in SPSS.

Thanks for the help, My First post!

Mark

been programming in SAS for 14 year and just jumped into SPSS.

In SAS you can combine a macro call and a text string very easily using a period.

i.e.

%let name = ted ;

data work1 ;
var = &name._is_fun ;
run ;

var would resolve to ted_is_fun

I cannot for the life of me figure out how to do this simply in SPSS.

Thanks for the help, My First post!

Mark

Share Improve this question asked Mar 21 at 22:16 Mark HedmanMark Hedman 252 bronze badges 2
  • Does the SPSS documentation Concatenate (General Concept) help? – Andrew Morton Commented Mar 21 at 22:22
  • stackoverflow/questions/43509275/… – Tom Commented Mar 22 at 16:15
Add a comment  | 

1 Answer 1

Reset to default 0

Here's a way to do this type of thing with SPSS macro (look up define - !enddefine in the documentation):

define !name(!pos=!tokens(1)) !concat("ted",!1) !enddefine.

This is a definition of a macro called !name which accepts one token after the macro call and concatenates it to the word "ted".

Now you're all set, you can call the macro this way for example:

frequencies !name _is_fun .

(this will be interpreted as frequencies ted_is_fun .

本文标签: creating a variableSPSS Macros vs SASStack Overflow