LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (April 1999)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 9 Apr 1999 16:15:40 -0400
Reply-To:     "Baker, Harley E,, DMDCWEST" <BAKERHE@OSD.PENTAGON.MIL>
Sender:       "SPSSX(r) Discussion" <SPSSX-L@UGA.CC.UGA.EDU>
From:         "Baker, Harley E,, DMDCWEST" <BAKERHE@OSD.PENTAGON.MIL>
Subject:      Re: Creating a Report from a set of TABLES
Comments: To: Donna Barre <dbarre@DOE.STATE.VT.US>

Yes, there is an easy way to accomplish what you want. Perhaps the easiest way is not to use loops etc, but to use the split file command as follows.

First, sort the cases by school. Second, split the file by school. Third, issue the tables commands.

So, the syntax would look like this:

sort cases by school. [assuming the var. name is school.]

split file by school. [same assumption.]

your tables commands.

This syntax will run whatever commands are inserted after the split file command for each value of school separately. So, it will do the tables for all cases where school eq 0, then for all cases for when schools eq 1, etc. Of course, if there are no cases where school eq 3, say, it would go on to the cases for which school eq 4.

This will do exactly what you requested:

Question: Is there a way to embed this set of Tables commands in a LOOP of some kind to do the following:Get data, Select cases for school 1, run all of these Tables commands, get full data set over again (or refresh the data set so that it contains all cases again), select cases for school 2, run tables, etc. BTW, the school numbering has some gaps, i.e., some numbers in the series of 1 through max# don't exist, or don't have any data for a particular grade level. If this can be done, should it be done in a script or macro, or can it be done within a syntax file.

To do it this way requires both the sort cases and the split file command, but you don't need a script, or loops, or anything.

Harley Baker

> -----Original Message----- > From: Donna Barre [SMTP:dbarre@DOE.STATE.VT.US] > Sent: Friday, April 09, 1999 12:53 PM > To: SPSSX-L@UGA.CC.UGA.EDU > Subject: Creating a Report from a set of TABLES > > This letter was previously posted on comp.soft-sys.stat.spss on 4/7/99, > but I have not seen it appear, so I'm reposting here. As this is my > first post, I hope I'm sending this to the appropriate audience. > > We would like to report aggregate results of a survey we conducted, > simply reporting the frequencies &/or percentages of individuals who > fell into each category of a variable (i.e., survey question). We did > this with TABLES (we have the custom tables module) when we aggregated > across our whole data set (all individuals who completed the survey). > We are now having a problem reporting survey results by subgroups (in > this case schools) because we cannot produce all of the results with one > Tables command. We want to produce a different "report" (a set of > tables) for each school. We think that a LOOP of some kind will work, > but don't know how to go about doing this. > > We have survey data where different answer categories were used in > different sets of questions. For example, questions 1-4 may have four > categories ranging from "strongly agree", "agree", "disagree", "strongly > disagree". Then questions 5-8 have five possible answers ranging from > "never" to "every day". We have created a set of commands in the tables > procedure using "custom tables, tables of frequencies" that handles > questions 1-4, then another one to handle questions 5-8, etc. as the > questions can be grouped when they have the same response categories. > This worked well enough when we didn't try to use a BY or subgrouping > variable. > > Here's some code we wrote to handle two sets of questions. There are > more blocks of code, but the important thing is that there is more than > one Tables command. > > * Table of Frequencies. > TABLES > /FORMAT BLANK MISSING('.') /TABLES > ( s1q2 + s1q3 + s1q4 ) BY > (LABELS) > (STATISTICS) > /STATISTICS CPCT ((PCT7.1) ' ') > /TITLE 'Section 1, English Language Arts,' + > 'Questions 2-4. How often do you do'+ > ' each of the following?'. > > * Table of Frequencies. > TABLES > /FORMAT BLANK MISSING('.') /TABLES > ( s1q5 + s1q6 + s1q7 + s1q8 + s1q9 + s1q10 + s1q11 + s1q12 ) BY > (LABELS) > (STATISTICS) > /STATISTICS CPCT ((PCT7.1) ' ' ) > /TITLE 'Section 1, English Language Arts,' + > 'Questions 5-12. When you have reading'+ > ' assignments in school, how often does your teacher do each of the'+ > ' following?'. > > > Question: Is there a way to embed this set of Tables commands in a LOOP > of some kind to do the following:Get data, Select cases for school 1, > run all of these Tables commands, get full data set over again (or > refresh the data set so that it contains all cases again), select cases > for school 2, run tables, etc. BTW, the school numbering has some gaps, > i.e., some numbers in the series of 1 through max# don't exist, or don't > have any data for a particular grade level. If this can be done, should > it be done in a script or macro, or can it be done within a syntax file. > > Alt question: Is there a way to make ONE Tables command handle all the > different table requests? > > Alt question #2: Is there another procedure other than TABLES that we > should be considering to do this task? > > We have tried a number of the options (layers, etc) in the TABLES pull > down menu and options boxes. The output doesn't come out looking like > the TABLES we created without the BY variable, and we'd like to send the > overall report and the BY-school reports out together, so we'd like them > to look the same. We have also tried to do a split file, but when we do > that it runs the first TABLES procedure for all schools, then the next > procedure for all schools etc. Is there a way to make the layers print > out off of these tables so we get the first layer of all tables, then > the second layer, etc? > > Thanks for your help! > > > D. Barre


Back to: Top of message | Previous page | Main SPSSX-L page