Hello, SPSS friends, I've got one more question which deals with CTABLES - CATEGORIES - Implicit Category Specification. The syntax reference gives following explanation for sorting categories by means (p.444-445 in SPSS 15.0 Command Syntax Reference): " Example CTABLES /TABLE AGE [MEAN F5.1] > CAR1 BY SEX /CATEGORIES VARIABLES=SEX TOTAL=YES /CATEGORIES VARIABLES=CAR1 KEY=MEAN(AGE). - The first CATEGORIES subcommand requests a total across the values of SEX. - The second CATEGORIES subcommand requests that the categories of CAR1 be sorted according to the mean of AGE. The categories are sorted according to the total means for both sexes, and that would be the case if the totals were not shown in the table. " And here's my question: Is there a way to sort means by the first category of SEX, i.e. by the mean of males in this case? Any hint is welcome. Thanks a lot, Mario
Mario Giesel
Munich, Germany |
This is tricky. There isn't a straightforward
way to do this that I could think of, but there are two possibilities.
Here is an example.
First I computed the variable maleage so that it is sysmis for females. Then I ran this table, which does the required sorting but duplicates the table with extra rows for the maleage variable. CTABLES /TABLE (age + maleage)[MEAN]> educ BY gender /CATEGORIES VARIABLES=educ ORDER=A KEY=MEAN (maleage) total=yes MISSING=EXCLUDE /CATEGORIES VARIABLES=gender EMPTY=INCLUDE total=yes. So I used this extension command, which requires the Python Essentials, to hide all the "maleage" rows. SPSSINC MODIFY TABLES subtype="'Custom Table'" SELECT="maleage" DIMENSION= ROWS LEVEL = 1 PROCESS = PRECEDING HIDE=TRUE /STYLES APPLYTO=DATACELLS. Note: in some versions of Statistics, row hiding does not work. The second approach is to use programmability to construct an explicit category list as a macro and then reference that in the relevant CATEGORIES subcommand. There is a function genSortedVariableExpr in the spssaux2.py module available from the SPSS Community site that does something similar to this. The Python plugin as far back as V15 is no longer available, though. If you want to keep Marso up all night, he might be able to concoct a way to do this without programmability. Regards, Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] new phone: 720-342-5621 From: Mario Giesel <[hidden email]> To: [hidden email] Date: 08/04/2012 12:18 PM Subject: [SPSSX-L] CTABLES: Sorting via Implicit Category Specification Sent by: "SPSSX(r) Discussion" <[hidden email]> Hello, SPSS friends, I've got one more question which deals with CTABLES - CATEGORIES - Implicit Category Specification. The syntax reference gives following explanation for sorting categories by means (p.444-445 in SPSS 15.0 Command Syntax Reference): " Example CTABLES /TABLE AGE [MEAN F5.1] > CAR1 BY SEX /CATEGORIES VARIABLES=SEX TOTAL=YES /CATEGORIES VARIABLES=CAR1 KEY=MEAN(AGE). - The first CATEGORIES subcommand requests a total across the values of SEX. - The second CATEGORIES subcommand requests that the categories of CAR1 be sorted according to the mean of AGE. The categories are sorted according to the total means for both sexes, and that would be the case if the totals were not shown in the table. " And here's my question: Is there a way to sort means by the first category of SEX, i.e. by the mean of males in this case? Any hint is welcome. Thanks a lot, Mario |
Free forum by Nabble | Edit this page |