```Date: Wed, 17 Nov 2010 16:20:36 +0000 Reply-To: "Salbod, Mr. Stephen" Sender: "SPSSX(r) Discussion" From: "Salbod, Mr. Stephen" Subject: Re: DO IF Comments: To: Bruce Weaver In-Reply-To: <1290009432780-3269261.post@n5.nabble.com> Content-Type: text/plain; charset="us-ascii" Bruce: To deal with the actual problem I did use recode. Now, I'm trying to understand why I cannot combine DO IF, IF, and DO IF into a single statement. I wondering if I'm missing a logical step related to short circuit behavior with sysmis. --Steve -----Original Message----- From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU] On Behalf Of Bruce Weaver Sent: Wednesday, November 17, 2010 10:57 AM To: SPSSX-L@LISTSERV.UGA.EDU Subject: Re: DO IF Right after posting, I noticed that Stephen does not want to recode SYSMIS to another value (for some reason). So I've modified the RECODE and computation of BOTH_IN_ONE as follows to avoid recoding SYSMIS to 9 in the original variables. recode practitioner StudentStat (missing=9) (else=copy) into #P #S . compute both_in_one = (#P*10) + #S. format both_in_one (f2.0). freq both_in_one. Bruce Weaver wrote: > > All those nested DO-IFs get complicated. I'd do something like this > instead. > > recode practitioner StudentStat (missing=9). > > compute both_in_one = (practitioner*10) + StudentStat. > format both_in_one (f2.0). > freq both_in_one. > > * If you need the originally stated group numbers, > * recode both_in_one into group. > > recode both_in_one > (11 = 1) > (12 = 2) > (21 = 3) > (22 = 4) > (99 = 5) > (91 = 6) > (92 = 7) > (19 = 8) > (29 = 9) into group. > freq group. > * Check that recode worked as intended. > crosstabs both_in_one by group. > > * Now assign value labels. > > > > Salbod, Mr. Stephen wrote: >> >> Dear Friends, >> >> I'm trying to combine following DO IF, IF, and DO IF into one DO IF. >> I don't want to recode sysmis into another value. >> When I've combined the codes under a single DO IF, and run the test >> data, I get only groups 1-4 and the rest missing. >> >> Any help will be greatly appreciated. >> >> TIA >> >> Stephen Salbod, Pace University, NYC >> >> >> DATA LIST / Practitioner 1 StudentStat 2 . >> BEGIN DATA >> 11 >> 12 >> 21 >> 22 >> >> 1 >> 2 >> 1 >> 2 >> END DATA. >> DO IF (Practitioner EQ 1 AND StudentStat EQ 1). >> COMPUTE group = 1. >> ELSE IF (Practitioner EQ 1 AND StudentStat EQ 2). >> COMPUTE group = 2. >> ELSE IF (Practitioner EQ 2 AND StudentStat EQ 1). >> COMPUTE group = 3. >> ELSE IF (Practitioner EQ 2 AND StudentStat EQ 2). >> COMPUTE group = 4. >> END IF. >> IF (MISSING(Practitioner) AND MISSING(StudentStat)) group = 5. >> DO IF (MISSING(Practitioner)). >> + DO IF (StudentStat EQ 1). >> + COMPUTE group = 6. >> + ELSE IF (StudentStat EQ 2). >> + COMPUTE group = 7. >> + END IF. >> ELSE IF (MISSING(StudentStat)). >> + DO IF (Practitioner EQ 1). >> + COMPUTE group = 8. >> + ELSE IF (Practitioner EQ 2). >> + COMPUTE group = 9. >> + END IF. >> END IF. >> EXECUTE. >> >> > > ----- -- Bruce Weaver bweaver@lakeheadu.ca http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." NOTE: My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/DO-IF-tp3269165p3269261.html Sent from the SPSSX Discussion mailing list archive at Nabble.com. ===================== To manage your subscription to SPSSX-L, send a message to LISTSERV@LISTSERV.UGA.EDU (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@LISTSERV.UGA.EDU (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 ```

Back to: Top of message | Previous page | Main SPSSX-L page