plotting % response > 0 for separate variables split by a categorical variable

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

plotting % response > 0 for separate variables split by a categorical variable

Christopher Stride
Hi all
I'm looking to plot the % of responses greater than 0 for several
different variables (e.g. responses to the same question at 10
timepoints) at once on the same graph, either as a line chart or a bar
chart.

Using the old style graphing facility in SPSS I can do this using either:

GRAPH  /LINE(SIMPLE)=PGT(0)(parent1 parent2 parent3 parent4 parent5
parent6 parent7
 parent8 parent9 parent10) /MISSING=VARIABLEWISE .

or

GRAPH  /BAR(SIMPLE)=PGT(0)(parent1 parent2 parent3 parent4 parent5
parent6 parent7
 parent8 parent9 parent10) /MISSING=VARIABLEWISE .

So far, no problem... but

However, what I'd then like to do is split the plot by groups defined by
a categorical variable i.e. for each variable, plot its % of responses
greater than 0 for each group defined by the categorical variable.

You can't do this easily via the old style graphing facility - for
instances, if I wanted a split by gender, if I tried

GRAPH  /LINE(SIMPLE)=PGT(0)(parent1 parent2 parent3 parent4 parent5
parent6 parent7
 parent8 parent9 parent10) by GENDER  /MISSING=VARIABLEWISE .

then I'd get different lines for each variable with gender on the
horizontal axis, whereas what i want is different lines for each gender,
with the variables across the horizontal axis.

I've actually written a macro to do the plot I want using the old
graphing facility, but I was wondering if anyone with expereince of the
'new' post-V14 graphing facility knew whether I could do it using that
and if so, how?  I haven't explored the new graphing facility much in
SPSS (I find that having to correct SPSS's incorrect guesses regarding
my variable types is very annoying) but I might be persuaded to if it
enables me to plot this graph! Any ideas?

cheers
Chris











--
[hidden email]

*** daytime: 0114 2223262 ***
***     FAX: 0114 2727206 ***


"Watford FC Supporters - South Yorkshire branch"

=====================
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: plotting % response > 0 for separate variables split by a categorical variable

ViAnn Beadle
To do this via the Chart Builder.

Drag the line element to the canvas.

Make all your parent variables scale variables in they are currently
classified as categorical by right-clicking on each one and setting it to
scale.

Shift-select all your parent variables (or control click if they are not
together).
Drag the selection to the Y axis to create a summary variable and an index
variable. The summary will be on y and the index on x.

The default statistic is mean, but you can change this to the percent
greater than in the Properties window.

Go to the point ID/grouping variable tab and check the grouping/stacking
box.

Drag gender to the dropzone.

Hit OK to run or Paste to paste it.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Dr
C B Stride
Sent: Monday, April 07, 2008 8:06 AM
To: [hidden email]
Subject: plotting % response > 0 for separate variables split by a
categorical variable

Hi all
I'm looking to plot the % of responses greater than 0 for several
different variables (e.g. responses to the same question at 10
timepoints) at once on the same graph, either as a line chart or a bar
chart.

Using the old style graphing facility in SPSS I can do this using either:

GRAPH  /LINE(SIMPLE)=PGT(0)(parent1 parent2 parent3 parent4 parent5
parent6 parent7
 parent8 parent9 parent10) /MISSING=VARIABLEWISE .

or

GRAPH  /BAR(SIMPLE)=PGT(0)(parent1 parent2 parent3 parent4 parent5
parent6 parent7
 parent8 parent9 parent10) /MISSING=VARIABLEWISE .

So far, no problem... but

However, what I'd then like to do is split the plot by groups defined by
a categorical variable i.e. for each variable, plot its % of responses
greater than 0 for each group defined by the categorical variable.

You can't do this easily via the old style graphing facility - for
instances, if I wanted a split by gender, if I tried

GRAPH  /LINE(SIMPLE)=PGT(0)(parent1 parent2 parent3 parent4 parent5
parent6 parent7
 parent8 parent9 parent10) by GENDER  /MISSING=VARIABLEWISE .

then I'd get different lines for each variable with gender on the
horizontal axis, whereas what i want is different lines for each gender,
with the variables across the horizontal axis.

I've actually written a macro to do the plot I want using the old
graphing facility, but I was wondering if anyone with expereince of the
'new' post-V14 graphing facility knew whether I could do it using that
and if so, how?  I haven't explored the new graphing facility much in
SPSS (I find that having to correct SPSS's incorrect guesses regarding
my variable types is very annoying) but I might be persuaded to if it
enables me to plot this graph! Any ideas?

cheers
Chris











--
[hidden email]

*** daytime: 0114 2223262 ***
***     FAX: 0114 2727206 ***


"Watford FC Supporters - South Yorkshire branch"

=====================
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

=====================
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
|

x = $sysmis ne missing(x)

Albert-Jan Roskam
Hi all,

I have a dataset with three postal codes (zip codes).
Usually, pc1 is recorded most reliably, pc2 is
intermediate, and pc3 is recorded least reliably. I
want to create a composite variable.

In the syntax below: why does case 3 evaluate as
sysmis? I want it to evaluate as '4567'. Idem, case 5:
I want pc4 to evaluate as '7890', the value of pc3.

Is the use of $sysmis completely undesirable? (I
remember something along those lines from previous
posts in this list) Should I use:
if (missing(pc1) and missing(pc2)) pc4 =
string(pc2,n4).
instead? I thought the two notations were equivalent?
Or am I missing(something) or something = $sysmis
something? ;-)

Cheers!!
Albert-Jan

* sample data.
data list free
  / pc1(n4) pc2 (n4) n_pc (n4) case (f2).
begin data
1234 4567 7890 1
1234    0 7890 2
   0 4567 7890 3
1234 4567    0 4
   0    0 7890 5
1234 4567 7890 6
end data.

recode all (0 = sysmis) (else = copy).

* postcode.
string pc4 (a4).
compute pc4 = string(pc1,n4).
if (pc1 = $sysmis and pc2 ne $sysmis) pc4 =
string(pc2,n4).
if (pc1 = $sysmis and pc2 = $sysmis) pc4 =
string(pc3,n4).



      ____________________________________________________________________________________
You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost.
http://tc.deals.yahoo.com/tc/blockbuster/text5.com

=====================
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: x = $sysmis ne missing(x)

Peck, Jon
Sysmis is never equal to anything, even itself.  Use the sysmis function to test a value for sysmis.

HTH,
Jon Peck

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Albert-jan Roskam
Sent: Monday, April 07, 2008 8:46 AM
To: [hidden email]
Subject: [SPSSX-L] x = $sysmis ne missing(x)

Hi all,

I have a dataset with three postal codes (zip codes).
Usually, pc1 is recorded most reliably, pc2 is
intermediate, and pc3 is recorded least reliably. I
want to create a composite variable.

In the syntax below: why does case 3 evaluate as
sysmis? I want it to evaluate as '4567'. Idem, case 5:
I want pc4 to evaluate as '7890', the value of pc3.

Is the use of $sysmis completely undesirable? (I
remember something along those lines from previous
posts in this list) Should I use:
if (missing(pc1) and missing(pc2)) pc4 =
string(pc2,n4).
instead? I thought the two notations were equivalent?
Or am I missing(something) or something = $sysmis
something? ;-)

Cheers!!
Albert-Jan

* sample data.
data list free
  / pc1(n4) pc2 (n4) n_pc (n4) case (f2).
begin data
1234 4567 7890 1
1234    0 7890 2
   0 4567 7890 3
1234 4567    0 4
   0    0 7890 5
1234 4567 7890 6
end data.

recode all (0 = sysmis) (else = copy).

* postcode.
string pc4 (a4).
compute pc4 = string(pc1,n4).
if (pc1 = $sysmis and pc2 ne $sysmis) pc4 =
string(pc2,n4).
if (pc1 = $sysmis and pc2 = $sysmis) pc4 =
string(pc3,n4).



      ____________________________________________________________________________________
You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost.
http://tc.deals.yahoo.com/tc/blockbuster/text5.com

=====================
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

=====================
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: x = $sysmis ne missing(x)

Melissa Ives
In reply to this post by Albert-Jan Roskam
Instead of using sysmis, it seems that you could just say something like (untested).

If no values are changed or set as missing....
* postcode.
string pc4 (a4).
compute pc4 = string(pc1,n4).
if (pc1 = 0 and pc2 ge 0) pc4 = string(pc2,n4).
if (pc1 = 0 and pc2 = 0) pc4 = string(pc3,n4).

If you have already either converted to sysmis or set 0 as the missing value, then this should work...
* postcode.
string pc4 (a4).
compute pc4 = string(pc1,n4).
if (missing(pc1) and pc2 ge 0) pc4 = string(pc2,n4).
if (missing(pc1) and missing(pc2)) pc4 = string(pc3,n4).

Melissa

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Albert-jan Roskam
Sent: Monday, April 07, 2008 9:46 AM
To: [hidden email]
Subject: [SPSSX-L] x = $sysmis ne missing(x)

Hi all,

I have a dataset with three postal codes (zip codes).
Usually, pc1 is recorded most reliably, pc2 is intermediate, and pc3 is recorded least reliably. I want to create a composite variable.

In the syntax below: why does case 3 evaluate as sysmis? I want it to evaluate as '4567'. Idem, case 5:
I want pc4 to evaluate as '7890', the value of pc3.

Is the use of $sysmis completely undesirable? (I remember something along those lines from previous posts in this list) Should I use:
if (missing(pc1) and missing(pc2)) pc4 = string(pc2,n4).
instead? I thought the two notations were equivalent?
Or am I missing(something) or something = $sysmis something? ;-)

Cheers!!
Albert-Jan

* sample data.
data list free
  / pc1(n4) pc2 (n4) n_pc (n4) case (f2).
begin data
1234 4567 7890 1
1234    0 7890 2
   0 4567 7890 3
1234 4567    0 4
   0    0 7890 5
1234 4567 7890 6
end data.

recode all (0 = sysmis) (else = copy).

* postcode.
string pc4 (a4).
compute pc4 = string(pc1,n4).
if (pc1 = $sysmis and pc2 ne $sysmis) pc4 = string(pc2,n4).
if (pc1 = $sysmis and pc2 = $sysmis) pc4 = string(pc3,n4).



      ____________________________________________________________________________________
You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost.
http://tc.deals.yahoo.com/tc/blockbuster/text5.com

=====================
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

PRIVILEGED AND CONFIDENTIAL INFORMATION
This transmittal and any attachments may contain PRIVILEGED AND
CONFIDENTIAL information and is intended only for the use of the
addressee. If you are not the designated recipient, or an employee
or agent authorized to deliver such transmittals to the designated
recipient, you are hereby notified that any dissemination,
copying or publication of this transmittal is strictly prohibited. If
you have received this transmittal in error, please notify us
immediately by replying to the sender and delete this copy from your
system. You may also call us at (309) 827-6026 for assistance.

=====================
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: x = $sysmis ne missing(x)

Spousta Jan
In reply to this post by Albert-Jan Roskam
Hi  Albert-Jan,

Instead of pc1 = $sysmis, use the function sysmis(pc1).  But it is possible to write

compute pc4 = string(pc3,n4).
if pc2 > 0 pc4 = string(pc2,n4).
if pc1 > 0 pc4 = string(pc1,n4).
exe.

Which is a bit clearer, I think. Pay attention to the reversed order of variables in the commands (3 to 1, not 1 to 3 as you used in your version).

Best regards

Jan

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Albert-jan Roskam
Sent: Monday, April 07, 2008 4:46 PM
To: [hidden email]
Subject: x = $sysmis ne missing(x)

Hi all,

I have a dataset with three postal codes (zip codes).
Usually, pc1 is recorded most reliably, pc2 is intermediate, and pc3 is recorded least reliably. I want to create a composite variable.

In the syntax below: why does case 3 evaluate as sysmis? I want it to evaluate as '4567'. Idem, case 5:
I want pc4 to evaluate as '7890', the value of pc3.

Is the use of $sysmis completely undesirable? (I remember something along those lines from previous posts in this list) Should I use:
if (missing(pc1) and missing(pc2)) pc4 = string(pc2,n4).
instead? I thought the two notations were equivalent?
Or am I missing(something) or something = $sysmis something? ;-)

Cheers!!
Albert-Jan

* sample data.
data list free
  / pc1(n4) pc2 (n4) n_pc (n4) case (f2).
begin data
1234 4567 7890 1
1234    0 7890 2
   0 4567 7890 3
1234 4567    0 4
   0    0 7890 5
1234 4567 7890 6
end data.

recode all (0 = sysmis) (else = copy).

* postcode.
string pc4 (a4).
compute pc4 = string(pc1,n4).
if (pc1 = $sysmis and pc2 ne $sysmis) pc4 = string(pc2,n4).
if (pc1 = $sysmis and pc2 = $sysmis) pc4 = string(pc3,n4).



      ____________________________________________________________________________________
You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost.
http://tc.deals.yahoo.com/tc/blockbuster/text5.com

=====================
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



_____

Tato zpráva a všechny připojené soubory jsou důvěrné a určené výlučně adresátovi(-ům). Jestliže nejste oprávněným adresátem, je zakázáno jakékoliv zveřejňování, zprostředkování nebo jiné použití těchto informací. Jestliže jste tento mail dostali neoprávněně, prosím, uvědomte odesilatele a smažte zprávu i přiložené soubory. Odesilatel nezodpovídá za jakékoliv chyby nebo opomenutí způsobené tímto přenosem.

This message and any attached files are confidential and intended solely for the addressee(s). Any publication, transmission or other use of the information by a person or entity other than the intended addressee is prohibited. If you receive this in error please contact the sender and delete the message as well as all attached documents. The sender does not accept liability for any errors or omissions as a result of the transmission.

-.- --

=====================
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: x = $sysmis ne missing(x)

Art Kendall
In reply to this post by Albert-Jan Roskam
I haven't finished reinstalling SPSS so cannot test the syntax.
<on soapbox>
*Since you already have zero as a value, why use $sysmis which should be
used only 1) when data cannot not be read into a meaningful value either
legit or with a known reason for being missing or 2) when a
transformation is not able to perform as directed? In the long run,
developing this habit will make it a lot easier to debug syntax.
Also note that using the traditional operators 1) avoids confusion
between = as a logical operator and as an assignment operator and two
makes the vertical alignment of your syntax easier.
*<off soapbox>

first remove the recode.
use the editor to replace 0 with 0 in your syntax.
add a list command.
try the new syntax.
did that do what you want?

string pc4 (a4).
compute pc4 = string(pc1,n4).
if (pc1 eq 0 and pc2 ne 0) pc4 = string(pc2,n4).
if (pc1 eq 0 and pc2 eq 0) pc4 = string(pc3,n4).
list.


Art Kendall
Social Research Consultants


Albert-jan Roskam wrote:

> Hi all,
>
> I have a dataset with three postal codes (zip codes).
> Usually, pc1 is recorded most reliably, pc2 is
> intermediate, and pc3 is recorded least reliably. I
> want to create a composite variable.
>
> In the syntax below: why does case 3 evaluate as
> sysmis? I want it to evaluate as '4567'. Idem, case 5:
> I want pc4 to evaluate as '7890', the value of pc3.
>
> Is the use of $sysmis completely undesirable? (I
> remember something along those lines from previous
> posts in this list) Should I use:
> if (missing(pc1) and missing(pc2)) pc4 =
> string(pc2,n4).
> instead? I thought the two notations were equivalent?
> Or am I missing(something) or something = $sysmis
> something? ;-)
>
> Cheers!!
> Albert-Jan
>
> * sample data.
> data list free
>   / pc1(n4) pc2 (n4) n_pc (n4) case (f2).
> begin data
> 1234 4567 7890 1
> 1234    0 7890 2
>    0 4567 7890 3
> 1234 4567    0 4
>    0    0 7890 5
> 1234 4567 7890 6
> end data.
>
>
> * postcode.
> string pc4 (a4).
> compute pc4 = string(pc1,n4).
> if (pc1 = $sysmis and pc2 ne $sysmis) pc4 =
> string(pc2,n4).
> if (pc1 = $sysmis and pc2 = $sysmis) pc4 =
> string(pc3,n4).
>
>
>
>       ____________________________________________________________________________________
> You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost.
> http://tc.deals.yahoo.com/tc/blockbuster/text5.com
>
> =====================
> 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
>
>
>

=====================
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
Art Kendall
Social Research Consultants
Reply | Threaded
Open this post in threaded view
|

Re: x = $sysmis ne missing(x)

Albert-Jan Roskam
Dear Art, Melissa, Jon and Jan,

THANKS for your quick replies! I hope this was the
last time I made a mistake with this three-way logic.
It saves me about 76000 non-linkages in two datasets
I'm trying to link. *huge relief*! That saves a "gulp
on a drink", as we call it!

Cheers!
Albert-Jan


--- Art Kendall <[hidden email]> wrote:

> I haven't finished reinstalling SPSS so cannot test
> the syntax.
> <on soapbox>
> *Since you already have zero as a value, why use
> $sysmis which should be
> used only 1) when data cannot not be read into a
> meaningful value either
> legit or with a known reason for being missing or 2)
> when a
> transformation is not able to perform as directed?
> In the long run,
> developing this habit will make it a lot easier to
> debug syntax.
> Also note that using the traditional operators 1)
> avoids confusion
> between = as a logical operator and as an assignment
> operator and two
> makes the vertical alignment of your syntax easier.
> *<off soapbox>
>
> first remove the recode.
> use the editor to replace 0 with 0 in your syntax.
> add a list command.
> try the new syntax.
> did that do what you want?
>
> string pc4 (a4).
> compute pc4 = string(pc1,n4).
> if (pc1 eq 0 and pc2 ne 0) pc4 = string(pc2,n4).
> if (pc1 eq 0 and pc2 eq 0) pc4 = string(pc3,n4).
> list.
>
>
> Art Kendall
> Social Research Consultants
>
>
> Albert-jan Roskam wrote:
> > Hi all,
> >
> > I have a dataset with three postal codes (zip
> codes).
> > Usually, pc1 is recorded most reliably, pc2 is
> > intermediate, and pc3 is recorded least reliably.
> I
> > want to create a composite variable.
> >
> > In the syntax below: why does case 3 evaluate as
> > sysmis? I want it to evaluate as '4567'. Idem,
> case 5:
> > I want pc4 to evaluate as '7890', the value of
> pc3.
> >
> > Is the use of $sysmis completely undesirable? (I
> > remember something along those lines from previous
> > posts in this list) Should I use:
> > if (missing(pc1) and missing(pc2)) pc4 =
> > string(pc2,n4).
> > instead? I thought the two notations were
> equivalent?
> > Or am I missing(something) or something = $sysmis
> > something? ;-)
> >
> > Cheers!!
> > Albert-Jan
> >
> > * sample data.
> > data list free
> >   / pc1(n4) pc2 (n4) n_pc (n4) case (f2).
> > begin data
> > 1234 4567 7890 1
> > 1234    0 7890 2
> >    0 4567 7890 3
> > 1234 4567    0 4
> >    0    0 7890 5
> > 1234 4567 7890 6
> > end data.
> >
> >
> > * postcode.
> > string pc4 (a4).
> > compute pc4 = string(pc1,n4).
> > if (pc1 = $sysmis and pc2 ne $sysmis) pc4 =
> > string(pc2,n4).
> > if (pc1 = $sysmis and pc2 = $sysmis) pc4 =
> > string(pc3,n4).
> >
> >
> >
> >
>
____________________________________________________________________________________

> > You rock. That's why Blockbuster's offering you
> one month of Blockbuster Total Access, No Cost.
> > http://tc.deals.yahoo.com/tc/blockbuster/text5.com
> >
> > =====================
> > 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
> >
> >
> >
>



      ____________________________________________________________________________________
You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost.
http://tc.deals.yahoo.com/tc/blockbuster/text5.com

=====================
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