macro to create CTABLE

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

macro to create CTABLE

nuptse

 

I am trying to write a macro to create a series of custom tables in SPSS. I used the following macro but it does not work. Any suggestions are highly appreciated.

 

Thanks

 

DEFINE !CustomTabs(!POSITIONAL !TOKENS(1))

 

*DATASET ACTIVATE PrePostMeasures.

CTABLES

  /VLABELS VARIABLES=location prepost 1! DISPLAY=LABEL

  /TABLE BY location [C] > prepost [C] BY 1! [S][MEAN F40.2, STDDEV F40.2, COUNT F40.0]

  /SLABELS POSITION=ROW

  /CATEGORIES VARIABLES=location prepost ORDER=A KEY=VALUE EMPTY=INCLUDE

  /TITLES

    TITLE='Mean and Standard Deviation of var1 by Location and Pre-Post Status'.

!ENDDEFINE.

 

!CustomTabs var1.

 

 

Error Message:

 

Error # 6846 in column 39.  Text: !

A macro expression includes an undefined macro variable or a macro operator

which is not valid within an expression.

Execution of this command stops.

 

Error # 6846 in column 43.  Text: !

A macro expression includes an undefined macro variable or a macro operator

which is not valid within an expression.

 

 

-- 
Dinesh Sharma, Ph.D.
Department of Mathematics and Statistics
321 Roop Hall, MSC 1911
James Madison University
Harrisonburg, VA 22807

Ph: (540) 568-6404
Fax: (540) 568-6857

 

===================== 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
Reply | Threaded
Open this post in threaded view
|

Re: macro to create CTABLE

Bruce Weaver
Administrator
Have you tried this?

SET MPRINT ON.
!CustomTabs var1.
SET MPRINT OFF.


Sharma, Dinesh Raj - sharmadr wrote
I am trying to write a macro to create a series of custom tables in SPSS. I used the following macro but it does not work. Any suggestions are highly appreciated.

Thanks

DEFINE !CustomTabs(!POSITIONAL !TOKENS(1))

*DATASET ACTIVATE PrePostMeasures.
CTABLES
  /VLABELS VARIABLES=location prepost 1! DISPLAY=LABEL
  /TABLE BY location [C] > prepost [C] BY 1! [S][MEAN F40.2, STDDEV F40.2, COUNT F40.0]
  /SLABELS POSITION=ROW
  /CATEGORIES VARIABLES=location prepost ORDER=A KEY=VALUE EMPTY=INCLUDE
  /TITLES
    TITLE='Mean and Standard Deviation of var1 by Location and Pre-Post Status'.
!ENDDEFINE.

!CustomTabs var1.


Error Message:

Error # 6846 in column 39.  Text: !
A macro expression includes an undefined macro variable or a macro operator
which is not valid within an expression.
Execution of this command stops.

Error # 6846 in column 43.  Text: !
A macro expression includes an undefined macro variable or a macro operator
which is not valid within an expression.


--
Dinesh Sharma, Ph.D.
Department of Mathematics and Statistics
321 Roop Hall, MSC 1911
James Madison University
Harrisonburg, VA 22807

Ph: (540) 568-6404
Fax: (540) 568-6857


=====================
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
--
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/).
Reply | Threaded
Open this post in threaded view
|

Re: macro to create CTABLE

David Marso
Administrator
Houston we have a problem ;-)
Correct usage is NOT 1! it would be !1 .
Please refer to the documentation for additional examples.
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?"
Reply | Threaded
Open this post in threaded view
|

Re: macro to create CTABLE

Bruce Weaver
Administrator
Well spotted, Hawkeye!  ;-)

David Marso wrote
Houston we have a problem ;-)
Correct usage is NOT 1! it would be !1 .
Please refer to the documentation for additional examples.
--
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/).
Reply | Threaded
Open this post in threaded view
|

Re: macro to create CTABLE

Jignesh Sutar
In reply to this post by nuptse
If you are going to create a macro to parameterise the input variable name then you may want to also do so in the CTABLE TITLE, so if the macro is re-used for anything else other than Var1  then the appropriate variable will be indicated in the title.

 For which you would use something like this:


/TITLES TITLE=!QUOTE(!CONCAT('Mean and Standard Deviation of ', !1, 'by Location and Pre-Post Status')).