Hello Team - I want to generate few (many) Custom Tables. I tried using PASTE option in spss, but it is generating lengthy syntax. Thus I have written below macro and run. Post run, SPSS throwing warnings and not generating any output. Could you please help me out!
define !tables() !do !i=R1 !TO R4 CTABLES /VLABELS VARIABLES=!i city AGE Sec DISPLAY=DEFAULT /TABLE !i BY city [C][COUNT F40.0, COLPCT.COUNT PCT40.1, TOTALS[COUNT 'Total' F40.0, COLPCT.COUNT PCT40.1]] + AGE [C][COUNT F40.0, COLPCT.COUNT PCT40.1] + Sec [C][COUNT F40.0, COLPCT.COUNT PCT40.1] /CATEGORIES VARIABLES=!i city AGE Sec ORDER=A KEY=VALUE EMPTY=INCLUDE TOTAL=YES POSITION=BEFORE. !doend !enddefine !tables. WARINING MESSAGES IN SPSS OUTPUT! >Warning # 228 >Invalid string found where numeric value required in macro expression. >Warning # 221 >Macro expansion found an error interpreting an operation code. Check the >arguments to functions and loop parameters for valid values. >Warning # 210 in column 1. Text: !ERROR_MACRO >A macro symbol is invalid in this context. >The symbol will be treated as an invalid special character. >Warning # 6870 in column 1. Text: !ERROR_MACRO >On the DEFINE command, there are symbols following !ENDDEFINE. These symbols >will be ignored. |
You need a period after !ENDDEFINE.(!)
Do you have sample data? /PR |
Hi PR, I corrected the syntax and run it again. But it didnt worked. I have sample data, but I am not sure where to upload/ share the data (am new to this forum). Can you please let me know how to share the data?
|
Hi,Ravindar, the construction !do !i=R1 !TO R4 will probably not work as it expects macro variables (variables with a '!' at the beginning). You cannot use SPSS variables here. Try define !tables(!POS !CMDEND) !DO !i !IN (!1) ... !DOEND !ENDDEFINE. !tables R1 R2 R3 R4. instead. GL, Mario RavindarG <[hidden email]> schrieb am 11:58 Mittwoch, 10.September 2014: Hi PR, I corrected the syntax and run it again. But it didnt worked. I have sample data, but I am not sure where to upload/ share the data (am new to this forum). Can you please let me know how to share the data? -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Error-while-running-the-do-loop-Need-Help-tp5727199p5727201.html Sent from the SPSSX Discussion mailing list archive at Nabble.com. ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Mario Giesel
Munich, Germany |
This post was updated on .
Thanks Mario. My spss got crashed a while back. I will run this code and will back incase of any further support!
Regards, Ravindar |
Administrator
|
In reply to this post by Mario Giesel
Another approach ;-).
Useful when the target has a consistent prefix and a numeric suffix. Easier than specifying a possibly large list of variables in the macro invocation DEFINE !tab (!POS !TOKENS(1)/!POS !TOKENS(1) /!POS !TOKENS(1) !DEFAULT (1) ). !DO !I=!3 !TO !2 !LET !var=!CONCAT(!1,!i) TABLES ..... !var BY blah blah ....... !DOEND !ENDDEFINE. !tab R 4.
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
Free forum by Nabble | Edit this page |