|
Dear list,
I hope this is clear I am quite new to SPSS and very new to syntax. I am trying to work out the average of an amount which could be in one of four variables. I select the cases I want to use with: COMPUTE filter_$=(SENT = 1 & (DISP1 = 530 or DISP2 = 530 or DISP3 = 530 or DISP4 = 530)). The amount I want the average for will either be in amount1, amount2, amount 3 or amount4 depending on whether its DISP1,2,3 or 4 =530.(530 cannot be in more than one DISP) And what I really want is If DISP1=530 then: MEANS TABLES=AMOUNT1 BY CRTTYPE BY OFFtype /CELLS MEAN. But if DISP2=530 then TABLES=AMOUNT2 BY CRTTYPE BY OFFtype /CELLS MEAN. And so on. And I want the average of all amounts split by CRTTYPE and OFFtype where any one of DISP 1-4=530 displayed in a single table I could run it four times and count the number of cases and work out the average myself but I will need to do this fairly regularly and would like to automate as much of it as possible I hope this is clear and possible to do Regards Graeme Fairnie Ministry of Justice 2 Marsham Street London SW1P 4DF [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 |
|
Hi Graeme
try creating a new var called amount which is the value of respective amountX for which dispX = 530. Then run mean tables on that. e.g. do repeat i = DISP1 DISP2 DISP3 DISP4 / j =AMOUNT1 AMOUNT2 AMOUNT3 AMOUNT4. if i = 530 AMOUNT = j. end repeat. MEANS TABLES = AMOUNT BY CRTTYPE BY OFFtype /CELLS MEAN. cheers Chris Graeme Fairnie wrote: > Dear list, > > I hope this is clear I am quite new to SPSS and very new to syntax. > > I am trying to work out the average of an amount which could be in one of > four variables. I select the cases I want to use with: > > COMPUTE filter_$=(SENT = 1 & (DISP1 = 530 or DISP2 = 530 or DISP3 = 530 or > DISP4 = 530)). > > The amount I want the average for will either be in amount1, amount2, > amount 3 or amount4 depending on whether its DISP1,2,3 or 4 =530.(530 > cannot be in more than one DISP) > > And what I really want is If DISP1=530 then: > MEANS > TABLES=AMOUNT1 BY CRTTYPE BY OFFtype > /CELLS MEAN. > > But if DISP2=530 then > TABLES=AMOUNT2 BY CRTTYPE BY OFFtype > /CELLS MEAN. > > And so on. > > And I want the average of all amounts split by CRTTYPE and OFFtype where > any one of DISP 1-4=530 displayed in a single table > > I could run it four times and count the number of cases and work out the > average myself but I will need to do this fairly regularly and would like > to automate as much of it as possible > > I hope this is clear and possible to do > > Regards > > Graeme Fairnie > Ministry of Justice > 2 Marsham Street > London > SW1P 4DF > [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 > -- “Figure It Out” Statistical Consultancy and Training Service for Social Scientists Visit www.figureitout.org.uk for details of my consultancy services and forthcoming training courses in November 2008 Dr Chris Stride, C. Stat, Statistician, Institute of Work Psychology, University of Sheffield Telephone: 0114 2223262 Fax: 0114 2727206 ===================== 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 |
|
In reply to this post by Graeme Fairnie
See if something like this untested syntax does what you want.
do if sent eq 1. compute myamount=-9999999. do repeat disp=disp1 disp2 disp3 disp4/ amount = amount1 amount2 amount3 amount4 / if disp eq 530 myamount=amount. end repeat. end if. missing values myamount (-9999999). MEANS TABLES=myamount BY CRTTYPE BY OFFtype /CELLS MEAN. If it does not do what you want please make up and post a small set of data with the relevant variables and a variable showing what you want it to be. Art Kendall Social Research Consultants Graeme Fairnie wrote: > Dear list, > > I hope this is clear I am quite new to SPSS and very new to syntax. > > I am trying to work out the average of an amount which could be in one of > four variables. I select the cases I want to use with: > > COMPUTE filter_$=(SENT = 1 & (DISP1 = 530 or DISP2 = 530 or DISP3 = 530 or > DISP4 = 530)). > > The amount I want the average for will either be in amount1, amount2, > amount 3 or amount4 depending on whether its DISP1,2,3 or 4 =530.(530 > cannot be in more than one DISP) > > And what I really want is If DISP1=530 then: > MEANS > TABLES=AMOUNT1 BY CRTTYPE BY OFFtype > /CELLS MEAN. > > But if DISP2=530 then > TABLES=AMOUNT2 BY CRTTYPE BY OFFtype > /CELLS MEAN. > > And so on. > > And I want the average of all amounts split by CRTTYPE and OFFtype where > any one of DISP 1-4=530 displayed in a single table > > I could run it four times and count the number of cases and work out the > average myself but I will need to do this fairly regularly and would like > to automate as much of it as possible > > I hope this is clear and possible to do > > Regards > > Graeme Fairnie > Ministry of Justice > 2 Marsham Street > London > SW1P 4DF > [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 > > > ===================== 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 |
| Free forum by Nabble | Edit this page |
