Dear SPSS users/experts, In my data set I have two variables: GENDER and Waist Hip Ratio(WHR). WHR is continuous. I want to recode WHR such that: For male:
For female:
I know how to do recoding for one group. But in my case the ranges vary by group (male vs female). I dont know how it will be done? Can someone suggest on how to do it? Thank you. Eins |
Can't you just employ the RECODE command with the DO IF option to create a new variable which has ranges that are gender-specific? i.e., DO IF (Gender=1) RECODE etc. etc.
END IF. DO IF (Gender=2) RECODE etc. etc. END IF. Ryan On Wed, Jan 23, 2013 at 10:16 PM, E. Bernardo <[hidden email]> wrote:
|
In reply to this post by E. Bernardo
Hi Eins,
Try to use filter while re-coding the data. Use
DO IF (expression). Recode ..... EndIF.
Hope this will work. Gaurav On Thu, Jan 24, 2013 at 8:46 AM, E. Bernardo <[hidden email]> wrote:
|
In reply to this post by Ryan
Eins I think there’s an error in your range for females: Low should be 0.6 – 0.69 ??. For a complete reply, try this (untested, and assuming no missing values which could be picked up by LO or HI). Also I’m not sure if the RECODE … INTO works for the same target variable. DO IF gender = 1 RECODE whr (low thru 0.9 = 1)(0.9 thru 0.95 = 2)(0.95 thru hi = 3) into whrgrp. ELSE IF gender = 2 RECODE whr (low thru 0.7 = 1)(0.7 thru 0.8 = 2)(0.8 thru hi = 3) into whrgrp. END IF. var lab whrgrp ‘Waist Hip Ratio Group’. val lab whrgrp 1 ‘Low WHR’ 2 ‘Generally healthy’ 3 ‘Abdominal Obesity’. freq whrgrp. cro whrgrp by gender /cel cou col. * or alternatively. cro gender by whrgrp /cel cou row. Do you know how to produce a single barchart displaying whrgrp for males and females separately? John F Hall (Mr) [retired academic survey researcher] Email: [hidden email] Website: www.surveyresearch.weebly.com From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of R B Can't you just employ the RECODE command with the DO IF option to create a new variable which has ranges that are gender-specific? i.e., DO IF (Gender=1) RECODE etc. etc. END IF. DO IF (Gender=2) RECODE etc. etc. END IF. Ryan On Wed, Jan 23, 2013 at 10:16 PM, E. Bernardo <[hidden email]> wrote: Dear SPSS users/experts, In my data set I have two variables: GENDER and Waist Hip Ratio(WHR). WHR is continuous. I want to recode WHR such that: For male:
For female:
I know how to do recoding for one group. But in my case the ranges vary by group (male vs female). I dont know how it will be done? Can someone suggest on how to do it? Thank you. Eins |
Administrator
|
I would certainly rethink that approach John (Your boundaries are WRONG) !!!
Non integers should always be recoded from Right to Left . -- data list free / gender whr. begin data 2 .5 2 .69 2 .70 2 .79 2 .80 2 99 2 .89 1 .90 1 .94 1 .95 1 1 1 -1 end data MISSING VALUES whr (-1,99). FREQ whr. DO IF NOT MISSING (whr). + DO IF gender = 1 . + RECODE whr (0.95 thru hi = 3) (0.9 thru 0.95 = 2)(low thru 0.9 = 1)into whrgrp. + ELSE IF gender = 2 . + RECODE whr (0.8 thru hi = 3) (0.7 thru 0.8 = 2)(low thru 0.7 = 1)into whrgrp. + END IF. ELSE. + COMPUTE whrgrp=VALUE(whr). END IF. MISSING VALUES whrgrp (-1,99). FREQ whrgrp. LIST. GENDER WHR WHRGRP 2.00 .50 1.00 2.00 .69 1.00 2.00 .70 2.00 2.00 .79 2.00 2.00 .80 3.00 2.00 99.00 99.00 2.00 .89 3.00 1.00 .90 2.00 1.00 .94 2.00 1.00 .95 3.00 1.00 1.00 3.00 1.00 -1.00 -1.00 Number of cases read: 12 Number of cases listed: 12 * John's way (OOPS). DO IF gender = 1 . RECODE whr (low thru 0.9 = 1)(0.9 thru 0.95 = 2)(0.95 thru hi = 3) into whrgrp. ELSE IF gender = 2 . RECODE whr (low thru 0.7 = 1)(0.7 thru 0.8 = 2)(0.8 thru hi = 3) into whrgrp. END IF. LIST. GENDER WHR WHRGRP 2.00 .50 1.00 2.00 .69 1.00 2.00 .70 1.00 2.00 .79 2.00 2.00 .80 2.00 2.00 99.00 3.00 2.00 .89 3.00 1.00 .90 1.00 1.00 .94 2.00 1.00 .95 2.00 1.00 1.00 3.00 1.00 -1.00 1.00 Number of cases read: 12 Number of cases listed: 12.
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
Like I said, it was untested, but in my days it made no difference.
Interesting to see if the outcome is the same or not. John F Hall (Mr) [retired academic survey researcher] Email: [hidden email] Website: www.surveyresearch.weebly.com -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of David Marso Sent: 24 January 2013 13:23 To: [hidden email] Subject: Re: Recoding values I would certainly rethink that approach John (Your boundaries are WRONG) !!! Non integers should always be recoded from Right to Left . -- data list free / gender whr. begin data 2 .5 2 .69 2 .70 2 .79 2 .80 2 99 2 .89 1 .90 1 .94 1 .95 1 1 1 -1 end data MISSING VALUES whr (-1,99). FREQ whr. DO IF NOT MISSING (whr). + DO IF gender = 1 . + RECODE whr (0.95 thru hi = 3) (0.9 thru 0.95 = 2)(low thru 0.9 = + 1)into whrgrp. + ELSE IF gender = 2 . + RECODE whr (0.8 thru hi = 3) (0.7 thru 0.8 = 2)(low thru 0.7 = + 1)into whrgrp. + END IF. ELSE. + COMPUTE whrgrp=VALUE(whr). END IF. MISSING VALUES whrgrp (-1,99). FREQ whrgrp. LIST. GENDER WHR WHRGRP 2.00 .50 1.00 2.00 .69 1.00 2.00 .70 2.00 2.00 .79 2.00 2.00 .80 3.00 2.00 99.00 99.00 2.00 .89 3.00 1.00 .90 2.00 1.00 .94 2.00 1.00 .95 3.00 1.00 1.00 3.00 1.00 -1.00 -1.00 Number of cases read: 12 Number of cases listed: 12 * John's way (OOPS). DO IF gender = 1 . RECODE whr (low thru 0.9 = 1)(0.9 thru 0.95 = 2)(0.95 thru hi = 3) into whrgrp. ELSE IF gender = 2 . RECODE whr (low thru 0.7 = 1)(0.7 thru 0.8 = 2)(0.8 thru hi = 3) into whrgrp. END IF. LIST. GENDER WHR WHRGRP 2.00 .50 1.00 2.00 .69 1.00 2.00 .70 1.00 2.00 .79 2.00 2.00 .80 2.00 2.00 99.00 3.00 2.00 .89 3.00 1.00 .90 1.00 1.00 .94 2.00 1.00 .95 2.00 1.00 1.00 3.00 1.00 -1.00 1.00 Number of cases read: 12 Number of cases listed: 12. ----- Please reply to the list and not to my personal email. Those desiring my consulting or training services please feel free to email me. -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Recoding-values-tp5717629p5717 643.html Sent from the SPSSX Discussion mailing list archive at 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 ===================== 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 |
Administrator
|
"Interesting to see if the outcome is the same or not."
I listed both results and they are very different! FWIW: RECODE does the assignment in order of the clauses. Hence( LO THRU .70=1)(.70 THRU .8=2) etc incorrectly ASSIGNS the .7 to 1 group. Since we do not ever truly know the granularity of the data, recoding ranges should be done in the manner I previously posted. In your days I am sure it indeed made a difference, you just didn't notice it (ie there have been NO fundamental changes to the operations of RECODE in the past 20+ years). ---
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
A recode stops as soon as a condition is
met, so there is no need to partition the recode space as below.
That is error prone and tedious.
Use something like (LO THRU x1=1) )(LO THRU x2=2) ... so that boundaries are only expressed once. Also, the Visual Binner (on the Transform menu) makes it much easier to generate recodes by 1) specifying explicit boundaries (entries in a grid) 2) specifying band widths or number of bins and starting values 3) specifying percentiles 4) specifying bins based on mean and standard deviation. The binner shows the bin overlay on a histogram to help you see how it fits the data, as well. The Visual Binner will generate appropriate value labels for all these scenarios for you. If you are not using it, you are making extra, tedious, and error prone work for yourself. The binner was introduced in SPSS 14 IIRC, so most users should have it. As the designer of that feature, I'm rather partial to it, but I do believe that it's a much better way to go than either writing raw syntax or using the older RECODE dialogs in most cases. Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] new phone: 720-342-5621 From: David Marso <[hidden email]> To: [hidden email], Date: 01/24/2013 07:08 AM Subject: Re: [SPSSX-L] Recoding values Sent by: "SPSSX(r) Discussion" <[hidden email]> "Interesting to see if the outcome is the same or not." I listed both results and they are very different! FWIW: RECODE does the assignment in order of the clauses. Hence( LO THRU .70=1)(.70 THRU .8=2) etc incorrectly ASSIGNS the .7 to 1 group. Since we do not ever truly know the granularity of the data, recoding ranges should be done in the manner I previously posted. In your days I am sure it *indeed *made a difference, you just didn't notice it (ie there have been NO fundamental changes to the operations of RECODE in the past 20+ years). --- John F Hall wrote > Like I said, it was untested, but in my days it made no difference. > Interesting to see if the outcome is the same or not. > > > John F Hall (Mr) > [retired academic survey researcher] > > Email: > johnfhall@ > Website: www.surveyresearch.weebly.com > > > > > > -----Original Message----- > From: SPSSX(r) Discussion [mailto: > SPSSX-L@.UGA > ] On Behalf Of > David Marso > Sent: 24 January 2013 13:23 > To: > SPSSX-L@.UGA > Subject: Re: Recoding values > > I would certainly rethink that approach John (Your boundaries are WRONG) > !!! > Non integers should always be recoded from Right to Left . > -- > data list free / gender whr. > begin data > 2 .5 2 .69 2 .70 2 .79 2 .80 2 99 2 .89 > 1 .90 1 .94 1 .95 1 1 1 -1 > end data > > MISSING VALUES whr (-1,99). > FREQ whr. > > DO IF NOT MISSING (whr). > + DO IF gender = 1 . > + RECODE whr (0.95 thru hi = 3) (0.9 thru 0.95 = 2)(low thru 0.9 = > + 1)into > whrgrp. > + ELSE IF gender = 2 . > + RECODE whr (0.8 thru hi = 3) (0.7 thru 0.8 = 2)(low thru 0.7 = > + 1)into > whrgrp. > + END IF. > ELSE. > + COMPUTE whrgrp=VALUE(whr). > END IF. > MISSING VALUES whrgrp (-1,99). > FREQ whrgrp. > LIST. > > GENDER WHR WHRGRP > > 2.00 .50 1.00 > 2.00 .69 1.00 > 2.00 .70 2.00 > 2.00 .79 2.00 > 2.00 .80 3.00 > 2.00 99.00 99.00 > 2.00 .89 3.00 > 1.00 .90 2.00 > 1.00 .94 2.00 > 1.00 .95 3.00 > 1.00 1.00 3.00 > 1.00 -1.00 -1.00 > > > Number of cases read: 12 Number of cases listed: 12 > > * John's way (OOPS). > DO IF gender = 1 . > RECODE whr (low thru 0.9 = 1)(0.9 thru 0.95 = 2)(0.95 thru hi = 3) into > whrgrp. > ELSE IF gender = 2 . > RECODE whr (low thru 0.7 = 1)(0.7 thru 0.8 = 2)(0.8 thru hi = 3) into > whrgrp. > END IF. > LIST. > GENDER WHR WHRGRP > > 2.00 .50 1.00 > 2.00 .69 1.00 > 2.00 .70 1.00 > 2.00 .79 2.00 > 2.00 .80 2.00 > 2.00 99.00 3.00 > 2.00 .89 3.00 > 1.00 .90 1.00 > 1.00 .94 2.00 > 1.00 .95 2.00 > 1.00 1.00 3.00 > 1.00 -1.00 1.00 > > > Number of cases read: 12 Number of cases listed: 12. > > > > > > > > ----- > Please reply to the list and not to my personal email. > Those desiring my consulting or training services please feel free to > me. > -- > View this message in context: > http://spssx-discussion.1045642.n5.nabble.com/Recoding-values-tp5717629p5717 > 643.html > Sent from the SPSSX Discussion mailing list archive at Nabble.com. > > ===================== > To manage your subscription to SPSSX-L, send a message to > LISTSERV@.UGA > (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 > LISTSERV@.UGA > (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 ----- Please reply to the list and not to my personal email. Those desiring my consulting or training services please feel free to email me. -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Recoding-values-tp5717629p5717649.html Sent from the SPSSX Discussion mailing list archive at 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 |
Administrator
|
Fine and dandy:
Riddle me this: What syntax would be pasted to answer to original question (assume the variable to be recoded is continuous and the values .1, .2 .....9 belong to the upper recoded interval rather than the lower interval. Personally, wizards for the most part slow me down and I usually have to clean up after them. --
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
I've long since lost the original problem,
but here is the Visual Binner generated syntax for something similar with
boundaries assigned to the upper interval. The Binner is not a wizard.
It's a regular dialog (with a selection precursor).
* Visual Binning. *jobtime. RECODE jobtime (MISSING=COPY) (90 THRU HI=4) (80 THRU HI=3) (70 THRU HI=2) (LO THRU HI=1) (ELSE=SYSMIS) INTO jobtimebinned. VARIABLE LABELS jobtimebinned 'Months since Hire (Binned)'. FORMATS jobtimebinned (F5.0). VALUE LABELS jobtimebinned 1 '< 70' 2 '70 - 79' 3 '80 - 89' 4 '90+' 0 'missing'. MISSING VALUES jobtimebinned (0). VARIABLE LEVEL jobtimebinned (ORDINAL). Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] new phone: 720-342-5621 From: David Marso <[hidden email]> To: [hidden email], Date: 01/24/2013 09:38 AM Subject: Re: [SPSSX-L] Recoding values Sent by: "SPSSX(r) Discussion" <[hidden email]> Fine and dandy: Riddle me this: What syntax would be pasted to answer to original question (assume the variable to be recoded is continuous and the values .1, .2 .....9 belong to the upper recoded interval rather than the lower interval. Personally, wizards for the most part slow me down and I usually have to clean up after them. -- Jon K Peck wrote > A recode stops as soon as a condition is met, so there is no need to > partition the recode space as below. That is error prone and tedious. > Use something like > (LO THRU x1=1) )(LO THRU x2=2) ... > so that boundaries are only expressed once. > > Also, the Visual Binner (on the Transform menu) makes it much easier to > generate recodes by > 1) specifying explicit boundaries (entries in a grid) > 2) specifying band widths or number of bins and starting values > 3) specifying percentiles > 4) specifying bins based on mean and standard deviation. > > The binner shows the bin overlay on a histogram to help you see how it > fits the data, as well. > > The Visual Binner will generate appropriate value labels for all these > scenarios for you. If you are not using it, you are making extra, > tedious, and error prone work for yourself. > > The binner was introduced in SPSS 14 IIRC, so most users should have it. > > As the designer of that feature, I'm rather partial to it, but I do > believe that it's a much better way to go than either writing raw syntax > or using the older RECODE dialogs in most cases. > > > Jon Peck (no "h") aka Kim > Senior Software Engineer, IBM > peck@.ibm > new phone: 720-342-5621 > > > > > From: David Marso < > david.marso@ > > > To: > SPSSX-L@.uga > , > Date: 01/24/2013 07:08 AM > Subject: Re: [SPSSX-L] Recoding values > Sent by: "SPSSX(r) Discussion" < > SPSSX-L@.uga > > > > > > "Interesting to see if the outcome is the same or not." > I listed both results and they are very different! > FWIW: RECODE does the assignment in order of the clauses. > Hence( LO THRU .70=1)(.70 THRU .8=2) etc incorrectly ASSIGNS the .7 to 1 > group. > Since we do not ever truly know the granularity of the data, recoding > ranges > should be done in the manner I previously posted. > In your days I am sure it *indeed *made a difference, you just didn't > notice > it (ie there have been NO fundamental changes to the operations of RECODE > in > the past 20+ years). > --- > > John F Hall wrote >> Like I said, it was untested, but in my days it made no difference. >> Interesting to see if the outcome is the same or not. >> >> >> John F Hall (Mr) >> [retired academic survey researcher] >> >> Email: > >> johnfhall@ > >> Website: www.surveyresearch.weebly.com >> >> >> >> >> >> -----Original Message----- >> From: SPSSX(r) Discussion [mailto: > >> SPSSX-L@.UGA > >> ] On Behalf Of >> David Marso >> Sent: 24 January 2013 13:23 >> To: > >> SPSSX-L@.UGA > >> Subject: Re: Recoding values >> >> I would certainly rethink that approach John (Your boundaries are WRONG) >> !!! >> Non integers should always be recoded from Right to Left . >> -- >> data list free / gender whr. >> begin data >> 2 .5 2 .69 2 .70 2 .79 2 .80 2 99 2 .89 >> 1 .90 1 .94 1 .95 1 1 1 -1 >> end data >> >> MISSING VALUES whr (-1,99). >> FREQ whr. >> >> DO IF NOT MISSING (whr). >> + DO IF gender = 1 . >> + RECODE whr (0.95 thru hi = 3) (0.9 thru 0.95 = 2)(low thru 0.9 = >> + 1)into >> whrgrp. >> + ELSE IF gender = 2 . >> + RECODE whr (0.8 thru hi = 3) (0.7 thru 0.8 = 2)(low thru 0.7 = >> + 1)into >> whrgrp. >> + END IF. >> ELSE. >> + COMPUTE whrgrp=VALUE(whr). >> END IF. >> MISSING VALUES whrgrp (-1,99). >> FREQ whrgrp. >> LIST. >> >> GENDER WHR WHRGRP >> >> 2.00 .50 1.00 >> 2.00 .69 1.00 >> 2.00 .70 2.00 >> 2.00 .79 2.00 >> 2.00 .80 3.00 >> 2.00 99.00 99.00 >> 2.00 .89 3.00 >> 1.00 .90 2.00 >> 1.00 .94 2.00 >> 1.00 .95 3.00 >> 1.00 1.00 3.00 >> 1.00 -1.00 -1.00 >> >> >> Number of cases read: 12 Number of cases listed: 12 >> >> * John's way (OOPS). >> DO IF gender = 1 . >> RECODE whr (low thru 0.9 = 1)(0.9 thru 0.95 = 2)(0.95 thru hi = 3) into >> whrgrp. >> ELSE IF gender = 2 . >> RECODE whr (low thru 0.7 = 1)(0.7 thru 0.8 = 2)(0.8 thru hi = 3) into >> whrgrp. >> END IF. >> LIST. >> GENDER WHR WHRGRP >> >> 2.00 .50 1.00 >> 2.00 .69 1.00 >> 2.00 .70 1.00 >> 2.00 .79 2.00 >> 2.00 .80 2.00 >> 2.00 99.00 3.00 >> 2.00 .89 3.00 >> 1.00 .90 1.00 >> 1.00 .94 2.00 >> 1.00 .95 2.00 >> 1.00 1.00 3.00 >> 1.00 -1.00 1.00 >> >> >> Number of cases read: 12 Number of cases listed: 12. >> >> >> >> >> >> >> >> ----- >> Please reply to the list and not to my personal email. >> Those desiring my consulting or training services please feel free to >> me. >> -- >> View this message in context: >> > http://spssx-discussion.1045642.n5.nabble.com/Recoding-values-tp5717629p5717 > >> 643.html >> Sent from the SPSSX Discussion mailing list archive at Nabble.com. >> >> ===================== >> To manage your subscription to SPSSX-L, send a message to > >> LISTSERV@.UGA > >> (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 > >> LISTSERV@.UGA > >> (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 > > > > > > ----- > Please reply to the list and not to my personal email. > Those desiring my consulting or training services please feel free to > email me. > -- > View this message in context: > http://spssx-discussion.1045642.n5.nabble.com/Recoding-values-tp5717629p5717649.html > > Sent from the SPSSX Discussion mailing list archive at Nabble.com. > > ===================== > To manage your subscription to SPSSX-L, send a message to > LISTSERV@.UGA > (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 ----- Please reply to the list and not to my personal email. Those desiring my consulting or training services please feel free to email me. -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Recoding-values-tp5717629p5717656.html Sent from the SPSSX Discussion mailing list archive at 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 |
In reply to this post by David Marso
David
More than likely the data I dealt with in those days was integer. I note your correction on decimal data, but I would still be inclined to write (LO thru 0.699 = 1)(0.7 thru 0.799 = 2)(0.8 thru hi = 3) But then I'm neither a statistician, nor a programmer, apart from some Algol in 1965-68 for the Salford Survey Suite, abandoned in 1979 in favour of SPSS. John -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of David Marso Sent: 24 January 2013 15:05 To: [hidden email] Subject: Re: Recoding values "Interesting to see if the outcome is the same or not." I listed both results and they are very different! FWIW: RECODE does the assignment in order of the clauses. Hence( LO THRU .70=1)(.70 THRU .8=2) etc incorrectly ASSIGNS the .7 to 1 group. Since we do not ever truly know the granularity of the data, recoding ranges should be done in the manner I previously posted. In your days I am sure it *indeed *made a difference, you just didn't notice it (ie there have been NO fundamental changes to the operations of RECODE in the past 20+ years). --- John F Hall wrote > Like I said, it was untested, but in my days it made no difference. > Interesting to see if the outcome is the same or not. > > > John F Hall (Mr) > [retired academic survey researcher] > > Email: > johnfhall@ > Website: www.surveyresearch.weebly.com > > > > > > -----Original Message----- > From: SPSSX(r) Discussion [mailto: > SPSSX-L@.UGA > ] On Behalf Of > David Marso > Sent: 24 January 2013 13:23 > To: > SPSSX-L@.UGA > Subject: Re: Recoding values > > I would certainly rethink that approach John (Your boundaries are > WRONG) !!! > Non integers should always be recoded from Right to Left . > -- > data list free / gender whr. > begin data > 2 .5 2 .69 2 .70 2 .79 2 .80 2 99 2 .89 > 1 .90 1 .94 1 .95 1 1 1 -1 > end data > > MISSING VALUES whr (-1,99). > FREQ whr. > > DO IF NOT MISSING (whr). > + DO IF gender = 1 . > + RECODE whr (0.95 thru hi = 3) (0.9 thru 0.95 = 2)(low thru 0.9 = > + 1)into > whrgrp. > + ELSE IF gender = 2 . > + RECODE whr (0.8 thru hi = 3) (0.7 thru 0.8 = 2)(low thru 0.7 = > + 1)into > whrgrp. > + END IF. > ELSE. > + COMPUTE whrgrp=VALUE(whr). > END IF. > MISSING VALUES whrgrp (-1,99). > FREQ whrgrp. > LIST. > > GENDER WHR WHRGRP > > 2.00 .50 1.00 > 2.00 .69 1.00 > 2.00 .70 2.00 > 2.00 .79 2.00 > 2.00 .80 3.00 > 2.00 99.00 99.00 > 2.00 .89 3.00 > 1.00 .90 2.00 > 1.00 .94 2.00 > 1.00 .95 3.00 > 1.00 1.00 3.00 > 1.00 -1.00 -1.00 > > > Number of cases read: 12 Number of cases listed: 12 > > * John's way (OOPS). > DO IF gender = 1 . > RECODE whr (low thru 0.9 = 1)(0.9 thru 0.95 = 2)(0.95 thru hi = 3) > into whrgrp. > ELSE IF gender = 2 . > RECODE whr (low thru 0.7 = 1)(0.7 thru 0.8 = 2)(0.8 thru hi = 3) into > whrgrp. > END IF. > LIST. > GENDER WHR WHRGRP > > 2.00 .50 1.00 > 2.00 .69 1.00 > 2.00 .70 1.00 > 2.00 .79 2.00 > 2.00 .80 2.00 > 2.00 99.00 3.00 > 2.00 .89 3.00 > 1.00 .90 1.00 > 1.00 .94 2.00 > 1.00 .95 2.00 > 1.00 1.00 3.00 > 1.00 -1.00 1.00 > > > Number of cases read: 12 Number of cases listed: 12. > > > > > > > > ----- > Please reply to the list and not to my personal email. > Those desiring my consulting or training services please feel free to > email me. > -- > View this message in context: > http://spssx-discussion.1045642.n5.nabble.com/Recoding-values-tp571762 > 9p5717 > 643.html > Sent from the SPSSX Discussion mailing list archive at Nabble.com. > > ===================== > To manage your subscription to SPSSX-L, send a message to > LISTSERV@.UGA > (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 > LISTSERV@.UGA > (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 ----- Please reply to the list and not to my personal email. Those desiring my consulting or training services please feel free to email me. -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Recoding-values-tp5717629p5717 649.html Sent from the SPSSX Discussion mailing list archive at 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 ===================== 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 |
Administrator
|
So one day some legitimate value .6999 shows up! What do you do?
Do you believe it appropriate to make this assumption regarding the granularity of the measurement? Do you believe code should be robust against such possibilities? ---
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
In reply to this post by David Marso
At 07:23 AM 1/24/2013, David Marso wrote:
>Non integers should always be recoded from Right to Left . More particularly: all recodes should be written so all possible input values fall into the range of one of the RECODE clauses. (If you have a range of values you want to leave unmodified, use a clause with a COPY output keyword.) For non-integer inputs, capturing all possible values requires that the ranges overlap. That is, do *not* write RECODE WHR (LO THRU 0.89 = 1) /* Low WHR */ (0.9 THRU 0.94 = 2) /* Generally Healthy */ (0.95 THRU HI = 3) /* Abdominal Obesity */ INTO WHR_CAT. instead, write RECODE WHR (LO THRU 0.90 = 1) /* Low WHR */ (0.9 THRU 0.95 = 2) /* Generally Healthy */ (0.95 THRU HI = 3) /* Abdominal Obesity */ INTO WHR_CAT. (Note that the upper range boundaries are changed.) However, as Jon Peck reminded us, a RECODE statement applies the first clause that is satisfied. So the above code assigns boundary values, like 0.90, to the lower of the two ranges ("Low WHR"). For the more common convention of assigning boundary values to the higher of the ranges, take David Marso's advice and order the clauses from highest to lowest range: RECODE WHR (0.95 THRU HI = 3) /* Abdominal Obesity */ (0.9 THRU 0.95 = 2) /* Generally Healthy */ (LO THRU 0.90 = 1) /* Low WHR */ INTO WHR_CAT. Jon Peck is correct that in this case, all upper limits can be specified as HI, if you want. ===================== 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 David Marso
I go by what the request said. Not my problem if data values are outside
the range specified. At least I answered the original question in full, which is more than everyone else did. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of David Marso Sent: 24 January 2013 19:40 To: [hidden email] Subject: Re: Recoding values So one day some legitimate value .6999 shows up! What do you do? Do you believe it appropriate to make this assumption regarding the granularity of the measurement? Do you believe code should be robust against such possibilities? --- John F Hall wrote > David > > More than likely the data I dealt with in those days was integer. I > note your correction on decimal data, but I would still be inclined to > write (LO thru 0.699 = 1)(0.7 thru 0.799 = 2)(0.8 thru hi = 3) But > then I'm neither a statistician, nor a programmer, apart from some > Algol in 1965-68 for the Salford Survey Suite, abandoned in 1979 in > favour of SPSS. > > John > > -----Original Message----- > From: SPSSX(r) Discussion [mailto: > SPSSX-L@.UGA > ] On Behalf Of > David Marso > Sent: 24 January 2013 15:05 > To: > SPSSX-L@.UGA > Subject: Re: Recoding values > > "Interesting to see if the outcome is the same or not." > I listed both results and they are very different! > FWIW: RECODE does the assignment in order of the clauses. > Hence( LO THRU .70=1)(.70 THRU .8=2) etc incorrectly ASSIGNS the .7 > to 1 group. > Since we do not ever truly know the granularity of the data, recoding > ranges should be done in the manner I previously posted. > In your days I am sure it *indeed *made a difference, you just didn't > notice it (ie there have been NO fundamental changes to the operations > of RECODE in the past 20+ years). > --- > > John F Hall wrote >> Like I said, it was untested, but in my days it made no difference. >> Interesting to see if the outcome is the same or not. >> >> >> John F Hall (Mr) >> [retired academic survey researcher] >> >> Email: > >> johnfhall@ > >> Website: www.surveyresearch.weebly.com >> >> >> >> >> >> -----Original Message----- >> From: SPSSX(r) Discussion [mailto: > >> SPSSX-L@.UGA > >> ] On Behalf Of >> David Marso >> Sent: 24 January 2013 13:23 >> To: > >> SPSSX-L@.UGA > >> Subject: Re: Recoding values >> >> I would certainly rethink that approach John (Your boundaries are >> WRONG) !!! >> Non integers should always be recoded from Right to Left . >> -- >> data list free / gender whr. >> begin data >> 2 .5 2 .69 2 .70 2 .79 2 .80 2 99 2 .89 >> 1 .90 1 .94 1 .95 1 1 1 -1 >> end data >> >> MISSING VALUES whr (-1,99). >> FREQ whr. >> >> DO IF NOT MISSING (whr). >> + DO IF gender = 1 . >> + RECODE whr (0.95 thru hi = 3) (0.9 thru 0.95 = 2)(low thru 0.9 = >> + 1)into >> whrgrp. >> + ELSE IF gender = 2 . >> + RECODE whr (0.8 thru hi = 3) (0.7 thru 0.8 = 2)(low thru 0.7 = >> + 1)into >> whrgrp. >> + END IF. >> ELSE. >> + COMPUTE whrgrp=VALUE(whr). >> END IF. >> MISSING VALUES whrgrp (-1,99). >> FREQ whrgrp. >> LIST. >> >> GENDER WHR WHRGRP >> >> 2.00 .50 1.00 >> 2.00 .69 1.00 >> 2.00 .70 2.00 >> 2.00 .79 2.00 >> 2.00 .80 3.00 >> 2.00 99.00 99.00 >> 2.00 .89 3.00 >> 1.00 .90 2.00 >> 1.00 .94 2.00 >> 1.00 .95 3.00 >> 1.00 1.00 3.00 >> 1.00 -1.00 -1.00 >> >> >> Number of cases read: 12 Number of cases listed: 12 >> >> * John's way (OOPS). >> DO IF gender = 1 . >> RECODE whr (low thru 0.9 = 1)(0.9 thru 0.95 = 2)(0.95 thru hi = 3) >> into whrgrp. >> ELSE IF gender = 2 . >> RECODE whr (low thru 0.7 = 1)(0.7 thru 0.8 = 2)(0.8 thru hi = 3) into >> whrgrp. >> END IF. >> LIST. >> GENDER WHR WHRGRP >> >> 2.00 .50 1.00 >> 2.00 .69 1.00 >> 2.00 .70 1.00 >> 2.00 .79 2.00 >> 2.00 .80 2.00 >> 2.00 99.00 3.00 >> 2.00 .89 3.00 >> 1.00 .90 1.00 >> 1.00 .94 2.00 >> 1.00 .95 2.00 >> 1.00 1.00 3.00 >> 1.00 -1.00 1.00 >> >> >> Number of cases read: 12 Number of cases listed: 12. >> >> >> >> >> >> >> >> ----- >> Please reply to the list and not to my personal email. >> Those desiring my consulting or training services please feel free to >> email me. >> -- >> View this message in context: >> http://spssx-discussion.1045642.n5.nabble.com/Recoding-values-tp57176 >> 2 >> 9p5717 >> 643.html >> Sent from the SPSSX Discussion mailing list archive at Nabble.com. >> >> ===================== >> To manage your subscription to SPSSX-L, send a message to > >> LISTSERV@.UGA > >> (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 > >> LISTSERV@.UGA > >> (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 > > > > > > ----- > Please reply to the list and not to my personal email. > Those desiring my consulting or training services please feel free to > email me. > -- > View this message in context: > http://spssx-discussion.1045642.n5.nabble.com/Recoding-values-tp571762 > 9p5717 > 649.html > Sent from the SPSSX Discussion mailing list archive at Nabble.com. > > ===================== > To manage your subscription to SPSSX-L, send a message to > LISTSERV@.UGA > (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 > LISTSERV@.UGA > (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 ----- Please reply to the list and not to my personal email. Those desiring my consulting or training services please feel free to email me. -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Recoding-values-tp5717629p5717 661.html Sent from the SPSSX Discussion mailing list archive at 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 ===================== 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 |
Administrator
|
In reply to this post by Richard Ristow
Thank you, folks (especially Richard, David & Jon). This has been a useful tutorial on RECODE.
--
Bruce Weaver bweaver@lakeheadu.ca http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." PLEASE NOTE THE FOLLOWING: 1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. 2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/). |
Administrator
|
In reply to this post by John F Hall
LOL: Please review the thread, the OP Q., Your answer, my answer and the listings ;-(
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
Free forum by Nabble | Edit this page |