|
Hi
I need a bit more help with another SPSS macro. I am trying to create a macro that will accept variables to be summed. The macro has two arguments - the first the variable name for the sum function and the second is the variables to be summed. I want to keep the number of variables entered dynamic. The macro code runs with errors but when I call the macro it give me an error that I cannot figure out. The error says
"Text: !sumstrs3 "
Define !sumval (!positional !token(1) /!positional !cmdend) !LET !YCOPY=!2 !LET !firstvar = !HEAD(!YCOPY) !LET !YCOPY=!TAIL(!YCOPY) !let !test=!null
!DO !x !IN (!ycopy) !LET !sumfun= !concat(!HEAD(!YCOPY),",") !let !test=!concat(!test, !sumfun) !LET !YCOPY=!TAIL(!YCOPY) !doend !let !sumarg=!concat(!test, !firstvar). compute !1=sum(!sumarg). fre !1 /sta mean. !enddefine.
!sumfunction s3s4s5_sum s4 s5 s3.
Thanks in advance!
Ratna
Ratna Wynn
|
|
Administrator
|
Why not just use a simple COMPUTE statement, such as:
COMPUTE s3s4s5_sum = SUM(s4, s5, s3). As far as I can see, the macro has NO advantage over this.
--
Bruce Weaver bweaver@lakeheadu.ca http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." PLEASE NOTE THE FOLLOWING: 1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. 2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/). |
| Free forum by Nabble | Edit this page |
