Hi All,
I have one numeric variable with 11 values (e.g., N_Agency 1 thru 11). I would like to create 11 similar CTables for each value with the N_Agency variable. I have seen macros used with CTables to run similar tables for individual variables; however, I have yet to uncover syntax in the FM, Google, and Nabble that concern using multiple values... any suggestions, hints, etc., would be much appreciated. Thank you, Damir |
It would help if you can be as specific as possible and provide an example data mock-up and current CTABLE syntax. Off-the-cuff it sounds like either SPLIT FILE or using nesting in the table might get you what you want. Nesting too deep in CTABLES will produce an interactive control to pivot to the different subgroups, which is nice for interactivity but not so nice for printing off. I don't believe this is the behavior with SPLIT FILE though.
Difficult to give any more advice though without more specifics. |
Administrator
|
I concur with SPLIT FILES. Note there is either LAYERED or SPLIT option (peruse the FM for details).
SPLIT FILE needs to be preceded with a SORT (assuming the file is not already sorted). <RANT> IIRC CTABLES ignores LAYERED SPLIT FILES (**UTTERLY STUPID** DESIGN DECISION IMNSHO!!!!!!!). From the FM: "CTABLES ignores SPLIT FILE requests if layered splits (compare groups in the graphical user interface) are requested. You can compare groups by using the split variables at the highest nesting level for row variables. See the TABLE subcommand for nesting variables." DO WHAT I @#$$ ASK NOT WHAT YOU THINK I SHOULD DO IN MY SYNTAX and change my workflow! (ie move my SPLIT into /TABLE)! I don't own CTABLES so can't really test the extent of the resulting mayhem. </RANT> If you have a specific list of known values you could also use a MACRO with a !DO loop. I also request that you provide specifics in the future! !DEFINE mymacro (yourvar !TOKENS(1) / values !CMDEND). !DO !v !IN (!Values) TEMPORARY. SELECT IF (!yourvar EQ !v). <Your Table>. !DOEND !ENDDEFINE mymacro yourvar=var values=list_of_values .
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?" |
In reply to this post by Andy W
Thank you Andy,
Here is my syntax and CTABLE. I should mention that I would like 11 different tables and I have already tried SPLIT and LAYER with little success. USE ALL. DATASET ACTIVATE AGENCY_QRTREPORT. DATASET COPY PRE_RELEASE1 . DATASET ACTIVATE PRE_RELEASE1 . /*Pre-Release - RESTORE . SELECT IF YEAR LE 2013 . SELECT IF QUARTER LE 4. SELECT IF N_AGENCY EQ 1. /* I would like to repeat this 11 time... N_Agency 1 thru 11. EXECUTE . DATASET ACTIVATE PRE_RELEASE1. SORT CASES BY N_AGENCY. CTABLES /VLABELS VARIABLES=N_AGENCY YEAR QUARTER ADMISSIONS EXITS S_EXITS MSERVED MPEAK ADP CAPACITYX CAPACITY GRADT GRAD DISPLAY=LABEL /TABLE N_AGENCY [C] > YEAR [C] > QUARTER [C] BY ADMISSIONS [S][MEAN] + EXITS [S][MEAN] + S_EXITS [S][MEAN] + MSERVED [S][MEAN] + MPEAK [S][MEAN] + ADP [S][MEAN] + CAPACITYX [S][MEAN] + CAPACITY [S][MEAN] + GRADT [S][MEAN] + GRAD [S][MEAN] /SLABELS VISIBLE=NO /CATEGORIES VARIABLES=N_AGENCY QUARTER ORDER=A KEY=VALUE EMPTY=EXCLUDE /CATEGORIES VARIABLES=YEAR ORDER=A KEY=VALUE EMPTY=EXCLUDE /TITLES TITLE='Caseload Performance Indicators: Quarterly Average Daily Population Program Inception to December 2013' CAPTION='Caseload, Disposition and Succesful Completion Participants since program inception to December 2013.'+ 'Period Requested: Program inception to December 31, 2013. ' 'Date of Extract (DOE) April 14, 2014 '+ 'Research and Planning Unit, Criminal Justice Commission. '. |
Thank you Andy and David,
I was able to generate the 11 Ctables using the following syntax. It seems that the SEPARATE works with SPLIT and Ctables; however, LAYER did not. David, besides the FM, do you have any suggested readings on SPSS MARCOS? This would help me reduce the clutter and repetition in much of my syntax used to generate local reports/statistics. Regards, Damir *///MY SOLUTION ////////////////////////////////////////////////////////////////////////////////// . DATASET ACTIVATE AGENCY_QRTREPORT. DATASET COPY AGENCY . DATASET ACTIVATE AGENCY . /*PRE-RELEASE -C . SORT CASES BY N_AGENCY. SPLIT FILE SEPARATE BY N_AGENCY. /*THIS SPLITS OUTPUT TABLES SELECT IF YEAR LE 2013 . SELECT IF QUARTER LE 4. EXECUTE . CTABLES /VLABELS VARIABLES=N_AGENCY YEAR QUARTER ADMISSIONS EXITS S_EXITS MSERVED MPEAK ADP CAPACITYX CAPACITY GRADT GRAD DISPLAY=LABEL /TABLE N_AGENCY [C] > YEAR [C] > QUARTER [C] BY ADMISSIONS [S][MEAN] + EXITS [S][MEAN] + S_EXITS [S][MEAN] + MSERVED [S][MEAN] + MPEAK [S][MEAN] + ADP [S][MEAN] + CAPACITYX [S][MEAN] + CAPACITY [S][MEAN] + GRADT [S][MEAN] + GRAD [S][MEAN] /SLABELS VISIBLE=NO /CATEGORIES VARIABLES=N_AGENCY QUARTER ORDER=A KEY=VALUE EMPTY=EXCLUDE /CATEGORIES VARIABLES=YEAR ORDER=A KEY=VALUE EMPTY=EXCLUDE /TITLES TITLE='Caseload Performance Indicators: Quarterly Average Daily Population Program Inception to December 2013' CAPTION='Caseload, Disposition and Succesful Completion Participants since program inception to December 2013.'+ 'Period Requested: Program inception to December 31, 2013. ' 'Date of Extract (DOE) April 14, 2014 '+ 'Research and Planning Unit, Criminal Justice Commission. '. |
Administrator
|
"do you have any suggested readings on SPSS MARCOS?"
Nope, its all crap! -- http://spssx-discussion.1045642.n5.nabble.com/template/NamlServlet.jtp?macro=search_page&node=1068821&query=%22%21ENDDEFINE%22
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?" |
Thank you again David.
Damir |
Administrator
|
Chapters 6,7,8 of the following link aren't half bad, but in my NSH analysis most of the examples are trivial crap.
OTOH, I supplied most of the material examples for this training manual back in the mid 90's when I worked for SPSS inc ;-) So in all honesty, it's mostly CRAP (stated in retrospect almost 20 years later)! http://szoc.tarstud.hu/upload/szoc_szakirany_programmingwithspsssyntaxandmacros.pdf
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?" |
In reply to this post by DKUKEC
At 09:08 AM 4/23/2014, DKUKEC wrote:
>do you have any suggested readings on SPSS macros? Try chapter 6 in Levesque, Raynald, *SPSS® Programming and Data Management, 2nd Edition*; Chicago, SPSS, Inc., 2005. (The chapter on macros was dropped from later editions, in favor of Python.) I'm pretty sure the second edition is no longer available on-line; but as it was initially a free download, I'll feel free to send you the .PDF -- ask off-list. ===================== 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 |
The older editions of the Programming and
Data Management book are still available on Ray's website - all the way
back to SPSS 14.
http://www.spsstools.net/spss_programming.htm Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] phone: 720-342-5621 From: Richard Ristow <[hidden email]> To: [hidden email], Date: 04/23/2014 03:15 PM Subject: Re: [SPSSX-L] Macro and CTables Sent by: "SPSSX(r) Discussion" <[hidden email]> At 09:08 AM 4/23/2014, DKUKEC wrote: >do you have any suggested readings on SPSS macros? Try chapter 6 in Levesque, Raynald, *SPSS® Programming and Data Management, 2nd Edition*; Chicago, SPSS, Inc., 2005. (The chapter on macros was dropped from later editions, in favor of Python.) I'm pretty sure the second edition is no longer available on-line; but as it was initially a free download, I'll feel free to send you the .PDF -- ask off-list. ===================== 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 |
In reply to this post by Richard Ristow
Hi Richard,
Thank you for your email. I was able to find the 2nd edition on Levesque’s site. What I am now trying to figure out is whether to invest time in getting to know MACROs or simply focus on Python? Any views or suggestions would be welcomed… for example, is Python easy to learn or is it a completely new language when compared to SPSS syntax?
Sincerely, Damir
From: Richard Ristow [via SPSSX Discussion] [mailto:ml-node+[hidden email]]
At 09:08 AM 4/23/2014, DKUKEC wrote:
If you reply to this email, your message will be added to the discussion below: http://spssx-discussion.1045642.n5.nabble.com/Macro-and-CTables-tp5725599p5725640.html To unsubscribe from Macro and CTables,
click here. Under Florida law, e-mail addresses are public records. If you do not want your e-mail address released in response to a public records request, do not send electronic mail to this entity. Instead, contact this office by phone or in writing. |
In reply to this post by Jon K Peck
Thank you Jon,
Perhaps I am asking the wrong person; however, what would you recommend I do… learn Python or study up on MACROs…. I know, perhaps a stupid question. From my understanding Python is used in other software as well?
Cheers,
From: Jon K Peck [via SPSSX Discussion] [mailto:ml-node+[hidden email]]
The older editions of the Programming and Data Management book are still available on Ray's website - all the way back to SPSS 14.
If you reply to this email, your message will be added to the discussion below: http://spssx-discussion.1045642.n5.nabble.com/Macro-and-CTables-tp5725599p5725641.html To unsubscribe from Macro and CTables,
click here. Under Florida law, e-mail addresses are public records. If you do not want your e-mail address released in response to a public records request, do not send electronic mail to this entity. Instead, contact this office by phone or in writing. |
A lot would depend on
what you are going to do.
Are you writing software for production purposes that needs to be tweaked? In general statistical analysis for policy and forensic purposes, in the early years I wrote special purpose pieces in FORTRAN. As SPSS developed I used fewer and fewer About 1979, i was able to discard about 120 single purpose programs. In the late 80, i was able to get rid of a couple hundred more. Since I retired on 2001, there was only one occasion -- revisiting the Federalist Papers analysis where I had to have a new PYTHON solution. There are times when one needs to extend SPSS's capabilities. But if you look back through the archives for the last few years, you'll see that there have been several occasions when people asked about using macros or python. After the list asked them to describe what they wanted to do, list members were able to provide native SPSS solutions. If you have two or three occasions, where you think you need a macro or pythons, I suggest that you post to this list, describe what you would like to do, and ask advice about which to learn for that purpose. Art Kendall Social Research ConsultantsOn 4/28/2014 4:18 PM, DKUKEC [via SPSSX Discussion] wrote:
Art Kendall
Social Research Consultants |
In reply to this post by DKUKEC
Python is quite a popular language in the
scientific computing world, and it is widely taught in computer science
courses. If you look at the TIOBE language popularity index, flawed
though it is, Python is typically around #6 among all computer languages.
(C, C++, Java, are usually at the top).
Some SPSS traditionalists will say MACRO forever, but there is nothing that macro can do that Python can't, and Python can do many types of things that macro can't (at least without resorting to horrible, fragile, and hard to understand hacks). The Python solutions are generally simpler and clearer. The downside is that Python is a completely different language from traditional syntax while macro is more similar, and not all users will have it installed. Personally, I drink a glass of macro-knowlege-erasing magic potion on a regular basis. Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] phone: 720-342-5621 From: DKUKEC <[hidden email]> To: [hidden email], Date: 04/28/2014 03:53 PM Subject: Re: [SPSSX-L] Macro and CTables Sent by: "SPSSX(r) Discussion" <[hidden email]> Thank you Jon,
Perhaps I am asking the wrong person; however, what would you recommend I do… learn Python or study up on MACROs…. I know, perhaps a stupid question. From my understanding Python is used in other software as well?
Cheers,
From: Jon K Peck [via SPSSX Discussion]
[[hidden email][hidden
email]]
The older editions of the Programming and
Data Management book are still available on Ray's website - all the way
back to SPSS 14.
If you reply to this email, your message will be added to the discussion below: http://spssx-discussion.1045642.n5.nabble.com/Macro-and-CTables-tp5725599p5725641.html
Under Florida law, e-mail addresses are public records. If you do not want your e-mail address released in response to a public records request, do not send electronic mail to this entity. Instead, contact this office by phone or in writing. View this message in context: RE: Macro and CTables Sent from the SPSSX Discussion mailing list archive at Nabble.com.
|
Administrator
|
In reply to this post by DKUKEC
Why not both.
Macro is easy, takes about a week to get familiar with it, forever to master it. OTOH: Python is much more powerful (if you need it).
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 |