CTABLES percentages calculation

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

CTABLES percentages calculation

jagadishpchary
This post was updated on .
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: CTABLES percentages calculation

PRogman
Some help along the way... To get the Statements in correct order you need a
numeric value with labels or a long order command ['Statement 1', 'Statement
2',....] on the categories subcommand.

/PR

* Original *.
CTABLES
  /VLABELS    VARIABLES = Statement, R, Brand
              DISPLAY   = NONE
  /TABLE      Statement [COUNT '']
           BY R
            > Brand
  /SLABELS    VISIBLE   = NO
  /CATEGORIES VARIABLES = Statement  TOTAL = YES POSITION = BEFORE
  /TITLES     TITLE     = 'Patients new to biologics - Q15_Banner1:
Absolutes'
.
DELETE VARIABLES Resp RankSum StmntSum RnkPct.


* Rearranged, unwanted order*.
CTABLES
  /VLABELS    VARIABLES = Statement Brand R
              DISPLAY   = NONE
  /TABLE      Statement [C]
           BY Brand     [C]
            > R         [C][COUNT F8.0, ROWPCT.COUNT PCT8.0]
  /SLABELS    VISIBLE   = NO
  /CATEGORIES VARIABLES = Statement ORDER=A KEY=VALUE EMPTY=EXCLUDE
TOTAL=YES POSITION=BEFORE
  /CATEGORIES VARIABLES = Brand     ORDER=A KEY=VALUE EMPTY=EXCLUDE  
  /CATEGORIES VARIABLES = R         ORDER=A KEY=VALUE EMPTY=EXCLUDE
.
* Manual calculations *.
COMPUTE Resp = 1.

AGGREGATE
  /OUTFILE   = *  MODE = ADDVARIABLES
  /BREAK     = Brand Statement R
  /RankSum   = SUM(Resp).

AGGREGATE
  /OUTFILE   = *  MODE = ADDVARIABLES
  /BREAK     = Brand Statement
  /StmntSum  = SUM(Resp).

COMPUTE RnkPct = RankSum / StmntSum *100.

CTABLES
  /VLABELS    VARIABLES = Statement R Brand Resp RnkPct
              DISPLAY   = NONE
  /TABLE      Statement [C]
           BY R         [C]
            > Brand     [C]
            > (Resp     [S][SUM F8.0]
             + RnkPct   [S][MEAN PCT8.0])
  /SLABELS    VISIBLE   = NO
  /CATEGORIES VARIABLES = Statement ORDER=A KEY=VALUE EMPTY=EXCLUDE
TOTAL=YES POSITION=BEFORE
  /CATEGORIES VARIABLES = R Brand   ORDER=A KEY=VALUE EMPTY=EXCLUDE
.




--
Sent from: http://spssx-discussion.1045642.n5.nabble.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: CTABLES percentages calculation

jagadishpchary
Many thanks for the code.



--
Sent from: http://spssx-discussion.1045642.n5.nabble.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