Ratios in V13.0

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

Ratios in V13.0

Elaine LaBorde
I've got a TABLE I want to duplicate as a CTABLE. Here's what the original
looked like:

compute ratio=1.
val lab ratio 1 ''.
for ratio (f1.0).

var lab  ratio '  RATIO   Pos / Neg'.

tables
  /for cwi(25,10) box wra(' -/')
  /pti left 'May 14-18, 2008' cen
     '[REDACTED]'
     '[REDACTED]:  Weighted Tables'
     right 'PAGE )PAGE'
  /fto t2 'TOTAL'
  /table one +
     verxy + county + sd9city + gender + rage50 + rr9650 + rpartyts +
     r89ts + r90ts50 + rideol + voteidel + sexideol + partyusd + consist +
     rrconsis + orderrd + rorderrd + combosub + csgender + csage50 +
     rrace + rraceprt + d6 + d5a + d5b + d5c + d5d + d5e + r14 + r29 +
     q14q29so + interest + q4a + one by r5 + ratio + t2
  /sta cpc( r5 (pct4) '':
     verxy county sd9city gender rage50 rr9650 rpartyts r89ts r90ts50
     rideol voteidel sexideol partyusd consist rrconsis orderrd rorderrd
     combosub csgender csage50 rrace rraceprt d6 d5a d5b d5c d5d d5e
     r14 r29 q14q29so interest q4a ) cou(t2 '')
  /cor ' R5'.
set lis off.
set lis on.

Here what the results look like:

                                                            R5-[REDACTED]
I.D.


                             Positive  Negative  No opinion      Never
RATIO      TOTAL

heard of   Pos / Neg

TOTAL                      18%          5%         15%           62%
3.6:1         401

X - Y VERSION
Version X                 19%          5%         14%            62%
3.8:1        200
Version Y                 16%          5%         17%            62%
   3.2:1        201


I understand that the Ratio here is just Positive/Negative (18/5=3.6), but
how do I say that in syntax? Here's what I've tried:

compute temp1=0.
if (r2=1) temp1=1.
if (mis(r2)) temp1=3.

compute temp2=0.
if (r2=2) temp2=1.
if (mis(r2)) temp2=3.

mis val temp1 temp2 (3).

if (r2<3) ratio=(temp1/temp2)*100.
var lab ratio 'RATIO\nPos:Neg'.

for temp1 to ratio (f3.0).
var lev ratio (scale).
execute.

CTABLES
  /FORMAT EMPTY=BLANK MINCOLWIDTH=50 MAXCOLWIDTH=100 UNITS=POINTS
  /TABLE ONE + VERXY + COUNTY + SD9CITY + GENDER + RAGE50 + RR9650 +
          RPARTYTS + R89TS + R90TS50 + RIDEOL + VOTEIDEL + SEXIDEOL +
            PARTYUSD + CONSIST + RRCONSIS + RORDERRD + COMBOSUB +
            CSGENDER + CSAGE50 + RRACE + RRACEPRT + D6 + D5A + D5B +
            D5C + D5D + D5E + R14 + R29 + Q14Q29SO + INTEREST + Q4A + ONE
   BY R5 [ROWPCT.COUNT,' ',PCT4] + RATIO + TWO [TOTALS[COUNT,'']]
  /CATEGORIES VAR=ALL EMPTY=EXCLUDE MISSING=EXCLUDE
  /SLABELS POSITION=COLUMN VISIBLE=NO
  /TITLE CORNER='R5'.

I lose it here: "if (r2<3) ratio=(temp1/temp2)*100." I'm getting either a
zero, or an attempt to divide by zero, so I know it's not even close. And
how do you format it to get that nice look? (3.6:1)

The guy who wrote the original code told me, "I think that's just what the
PC+ version defaults to. When I was trying to do some work with the Windows
stuff a few months ago I couldn't figure that out either."

I'm sure there is a way to duplicate that. Does anyone know what it is?
Thank you!

--
Elaine LaBorde
[hidden email]

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

One observation on the stability of SPSS 17

Mark A Davenport MADAVENP
I never really had any lock-up problems with 16.  I had one memory fault
with the beta of 17 but was never able to replicate it.  Perhaps more
interesting is it DIDN'T lock up my machine and I lost no data because of
it. I continued to work throught the error to save everything and start up
again.  I lost nothing.  I did find that 17 was a bit faster on writing
output.  There are several sweet enhancements coming as well (smart syntax
editor with error-checking, multiple imputation with pooled statistics,
etc.)

***************************************************************************************************************************************************************
Mark A. Davenport Ph.D.
Senior Research Analyst
Office of Institutional Research
The University of North Carolina at Greensboro
336.256.0395
[hidden email]

'An approximate answer to the right question is worth a good deal more
than an exact answer to an approximate question.' --a paraphrase of J. W.
Tukey (1962)

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