Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

script or syntax for hiding rows needed

392 views
Skip to first unread message

shelley...@gmail.com

unread,
Apr 28, 2005, 5:13:00 PM4/28/05
to
I'm creating a lot of tables that include multiple variables, with Yes,
No and No Response as the answer categories. These are for "check all
that apply" type survey questions -- as in, please indicate your work
setting(s) (please check all that apply). Even though all I really
want is to know the % who have said Yes to each category, I have to
include all categories when running the tables, otherwise the %s would
be wrong. I know how to select a single row and hide it, but this gets
VERY onerous when there are many many tables.

I've looked at the sample scripts that are bundled with SPSS and I know
there's one that can be used to delete rows or columns in a Pivot
table based on the contents of the Row Labels or Column Labels. One
issue with this is that it seems to work only on a single Pivot Table,
and that table has to be selected. I would like to run it on an output
file and have it modify every table in the file, and I don't know if
that's possible with this script or not. I have a lot of titles and
captions and so on in my syntax, so the output has lots of stuff in it
along with the usual titles and notes and tables. I have almost no
experience with scripts and am hoping somebody in this group might be
able to give me a bit of guidance. Just looking at the script scares
me!

Richard Ulrich

unread,
Apr 28, 2005, 5:58:42 PM4/28/05
to
On 28 Apr 2005 14:13:00 -0700, shelley...@gmail.com wrote:

> I'm creating a lot of tables that include multiple variables, with Yes,
> No and No Response as the answer categories. These are for "check all
> that apply" type survey questions -- as in, please indicate your work
> setting(s) (please check all that apply). Even though all I really
> want is to know the % who have said Yes to each category, I have to
> include all categories when running the tables, otherwise the %s would
> be wrong. I know how to select a single row and hide it, but this gets
> VERY onerous when there are many many tables.

Have you looked at Mult Response?
That sounds ideal for what you've described so far,
or nearly ideal.

[snip, about scripts]

--
Rich Ulrich, wpi...@pitt.edu
http://www.pitt.edu/~wpilib/index.html

Lisa

unread,
Apr 28, 2005, 7:20:27 PM4/28/05
to
Hi Shelly,

I do this fairly regularly, but first I have a question. If I'm
understanding you right, you can (and do) have multiple responses from
a single respondent. What I need to know is do you need to calculate
the percentage based on the number of responses or the percentage based
on the number of respondents? i.e. What do you want your denominator
to be?

If you want the percentage of responses for some answer, then use
Crosstabs. You can request % totals for the row, col &/or grand total.


CROSSTABS
/TABLES=v3 BY v200
/FORMAT= AVALUE TABLES
/CELLS= COUNT ROW COLUMN TOTAL
/COUNT ROUND CELL .

To use the above code, just replace the v3 & V200 w/ your variable
names. The line marked /CELLS COUNT ROW COLUMN TOTAL tells SPSS what
to put in each box of the table. Count is the frequency of the item.
ROW gives you the percent w/ the row total in the denominator; COLUMN
is the percent w/ the col. total in the denominator, and TOTAL gives
you the % of the total sample. If you prefer using GUIs (pull-down
menus), then go to Analyze -> Descriptive Statistics -> Crosstabs.
Then in Crosstabs, click on CELLS to tell SPSS wshat you want it to
output in each cell.

If you want to calculate the percent based on the number of
respondents of your survey, then just filter out (Data -> Select Cases)
any non-respondents and run a frequency (Analysis -> Descriptive
Statistics -> Frequencies) for each posible answer. Frequencies
automatically give you the percentage and by filtering out the
non-respondents to a particular question, you are forcing the
denominator in the percentage equation to be the number of respondents.

USE ALL.
COMPUTE filter_$=(v3 <> 0 AND v3<>99).
VARIABLE LABEL filter_$ 'v3<>0 and v3<>99 (FILTER)'.
VALUE LABELS filter_$ 0 'Not Selected' 1 'Selected'.
FORMAT filter_$ (f1.0).
FILTER BY filter_$.
EXECUTE .

FREQUENCIES
VARIABLES=v3a v3b v3c v3d
/ORDER= ANALYSIS .


In the above I only include values of V3 that are not 0 and not 99
(both missing data in my file), then I ask for the frequencies of
options a, b, c, & d for v3 (my 4 "choose all" multiple choice
options). I hope this helps and good luck.

Best,
Lisa

shelley...@gmail.com

unread,
Apr 28, 2005, 7:46:28 PM4/28/05
to
No, I never considered multiple response tables as a way to do this,
and it actually comes very close to doing what I need - but I can't see
a way to make it do EXACTLY what I need!

All of the variables that I'm dealing with have three answer categories
-- 1=Yes, 2=No, 3=No Response. When creating a multiple response set
for a group of variables, I seem to have two options. The first is to
indicate that the variables are dichotomous and to list the value that
is to be counted (in my case, I want to count instances of 1 (yes=1).
If I do this and then run a multiple resp table, I can see that the
percentages aren't being calculated on the total of the cases --
they're being calculated on the total number of cases across teh first
two categories only, ignoring the cases in the third category (9=no
response).

The second option for creating multiple response sets counts any answer
in any category and kinda lumps things all together, which is not at
all what i need.

I've pasted the syntax that's generated when I create a multiple
response set for dichotomous vars to see if I can edit it to trick it
into considering all cases, not just those with answers in the first
two categories, to be used in the denominator for calculating the % of
Yes responses but don't think it can be done.

Recoding all of the relevant variables to lump together the "no" and"no
response" categories isn't an option for a variety of reasons.

More suggestions and advice will be very, very welcome!

shelley...@gmail.com

unread,
Apr 29, 2005, 5:05:31 AM4/29/05
to
Thanks for the suggestions, Lisa, but unfortunately they will not give
me what I need. I probably could have explained more clearly in my
original post!

Our survey included a question that asked physicians to tell us their
work setting(s), and provided them a list of 8 work settings with
instructions to check all that apply. Obviously, because this was a
"check all that apply" question, we have 8 variables, M1A through M1H,
rather than single variable. The answer categories after recoding are
Yes, No, and No Response.

I am using Basic Tables to create a single table of results for this
question. I've used the GUI to set up the table, with vars M1A to M1H
in the "Down" area, and have added count and percent statistics. This
generates a table of results that looks like this:

Private Office - Solo Yes 12819
60.2%
No
8334 39.1%
No Response 143
0.7%
Private Office - Group Yes
No
No Response
Walk-in Clinic Yes
No
No Response
Community Hospital Yes
No
No response
(etc)

All we want to display when we publish these data is the "Yes" counts
and percents. I cannot do anything by an underlying select of those
who said yes, because I am displaying 8 vars in the table and of course
the Yes count for each is different. And even if I could select just
the Yes cases, the percents would be 100% for each var because I would
have selected out the No and No Response cases.

I am looking for some fast way to take out the No and No Response lines
in each table. I can take the lines out manually using the Hide command
in the Output Viewer, but this would be agonizingly slow. Rich's
suggestion to use Multiple Response was excellent, but it only works
with dichotomous vars and mine have 3 categories -- and I would prefer
not to have to recode all the variables (there are many questions like
this on the survey and thus many, many vars that would have to be
recoded).

Again, advice will be greatly appreciated.

Bruce Weaver

unread,
Apr 29, 2005, 8:29:16 AM4/29/05
to
shelley.gro...@gmail.com wrote:
> Thanks for the suggestions, Lisa, but unfortunately they will not
give
> me what I need. I probably could have explained more clearly in my
> original post!
>
> Our survey included a question that asked physicians to tell us their
> work setting(s), and provided them a list of 8 work settings with
> instructions to check all that apply. Obviously, because this was a
> "check all that apply" question, we have 8 variables, M1A through
M1H,
> rather than single variable. The answer categories after recoding
are
> Yes, No, and No Response.
>
> I am using Basic Tables to create a single table of results for this
> question. I've used the GUI to set up the table, with vars M1A to
M1H
> in the "Down" area, and have added count and percent statistics. This
> generates a table of results that looks like this:
--- snip table ----

>
> All we want to display when we publish these data is the "Yes" counts
> and percents. I cannot do anything by an underlying select of those
> who said yes, because I am displaying 8 vars in the table and of
course
> the Yes count for each is different. And even if I could select just
> the Yes cases, the percents would be 100% for each var because I
would
> have selected out the No and No Response cases.
>
> I am looking for some fast way to take out the No and No Response
lines
> in each table. I can take the lines out manually using the Hide
command
> in the Output Viewer, but this would be agonizingly slow. Rich's
> suggestion to use Multiple Response was excellent, but it only works
> with dichotomous vars and mine have 3 categories -- and I would
prefer
> not to have to recode all the variables (there are many questions
like
> this on the survey and thus many, many vars that would have to be
> recoded).
>
> Again, advice will be greatly appreciated.


I don't understand the objection to recoding the variables, because the
whole lot of them can probably be recoded with one RECODE command.

Another possibility would be to use AGGREGATE to write the N's and
percentages responding YES to a separate file. Given how you want your
table to appear, you would probably have to RESTRUCTURE using
VARSTOCASES. You could then compute a new variable using $CASENUM, and
assign value labels that correspond to the original variables (down the
side of your table). Then create your table using SUMMARIZE or REPORT.
Frankly though, this seems like more work to me than recoding and
using MULTIPLE RESPONSE.

--
Bruce Weaver
bwe...@lakeheadu.ca
www.angelfire.com/wv/bwhomedir

shelley...@gmail.com

unread,
Apr 29, 2005, 9:36:57 AM4/29/05
to
Hi, Bruce

I know it seems odd to have voiced an objection to recoding the
variables, but there are valid reasons have to do with a data file that
(1) is shared among several partner orgs, with some partners wanting to
retain the current coding and (2) already contains 1200 variables (and
thus there is a reluctance to add another whack of vars to create the
dichotomous vars that would be needed to allow me to use multiple
response features -- about 200 in total).

The aggregation stuff gets a bit tricky, esp. again that several
partner orgs use the same database.

And you are quite right that multiple response is the easiest way to do
this, and I came to that conclusion about 3:00 this morning whilst
mulling this over instead of sleeping! I have just created a syntax
command that turns all of the relevant variables into dichotomous vars,
over top of the original vars instead of into new ones. Our plan is to
run this syntax on the file, then run the syntax I'm going to build to
generate the necessary tables, then close the file without saving the
changes to the vars. The syntax takes about 30 seconds to run, so it's
no big deal to run it when we need and just not save it. This gives us
the best of both worlds -- we retain the three-category vars that are
important for some purposes, but massage them temporarily into two
categories for some purposes.

Thanks for the idea to use multiple response for this problem -- I make
extensive use of the categorical multiple response function, but had
never done anything with the dichotmous function.

Regards,

Shelley Martin
Canadian Medical Association

Richard Ulrich

unread,
Apr 29, 2005, 2:05:04 PM4/29/05
to
On 29 Apr 2005 06:36:57 -0700, shelley...@gmail.com wrote:

> Hi, Bruce
>
> I know it seems odd to have voiced an objection to recoding the
> variables, but there are valid reasons have to do with a data file that
> (1) is shared among several partner orgs, with some partners wanting to
> retain the current coding and (2) already contains 1200 variables (and
> thus there is a reluctance to add another whack of vars to create the
> dichotomous vars that would be needed to allow me to use multiple
> response features -- about 200 in total).
>
> The aggregation stuff gets a bit tricky, esp. again that several
> partner orgs use the same database.
>
> And you are quite right that multiple response is the easiest way to do
> this, and I came to that conclusion about 3:00 this morning whilst
> mulling this over instead of sleeping! I have just created a syntax
> command that turns all of the relevant variables into dichotomous vars,
> over top of the original vars instead of into new ones. Our plan is to
> run this syntax on the file, then run the syntax I'm going to build to
> generate the necessary tables, then close the file without saving the
> changes to the vars. The syntax takes about 30 seconds to run, so it's
> no big deal to run it when we need and just not save it.

That's safe.

I believe that the reason the original omitted the counts
for (3) would be that (3) was defined as "MISSING VALUE";
so you might save a pass through the file if you just
turned off the Missing,
Missing values v1 to v200( ).

It is always safer to close a file without re-saving it if you
have not intended to change anything.

[... ]

neila...@msn.com

unread,
Apr 29, 2005, 6:17:43 PM4/29/05
to
Shelley,
Look into TEMPORARY command.
TEMPORARY .
RECODE varlist (1=1 )(ELSE=0).
TABLES blah blah blah.
Neila

shelley...@gmail.com

unread,
May 2, 2005, 6:45:24 PM5/2/05
to
This whole thing turned out to be SO much easier than I thought -- and
I am eternally grateful that my co. pays the annual maintenance fee to
SPSS, because it sure is useful when I'm tangling with some kind of
issue.

I made a wrong assumption when using the dichotomous var function
within multiple response sets -- I thought the underlying vars had to
be dichotomous, but in fact the do not! When creasting mult resp sets
this way, you specify a single value to be counted across all the vars
of interest, and SPSS then treats that as one value in the dichotomy,
and then treats ALL OTHER VALUES together as the other value in the
dichotomy.

I spent an hour on the phone with SPSS tech support trying to figure
out on what basis it was calculating the percentages when I ran my
multiple response tables and we couldn't sort out what it was doing.
However, what did get sorted out was that I needed to build my multiple
response tables in Custom Tables, where I would have a much broader
arsenal of available calculations for percents -- the one that I needed
to use to have the percents calculated on a denominator equal to the
number of cases is, I think, Count Total N % (or something like that --
I'm at home and writing from memory right now!).

I hope this all makes some sense. thanks to those who offered advice.

Shelley

0 new messages