Date: Sun, 18 Dec 2011 19:42:29 -0800
Reply-To: David Marso <david.marso@gmail.com>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: David Marso <david.marso@gmail.com>
Subject: Re: use value computed in 'do repeat' within 'do repeat'
In-Reply-To: <1324135495068-5082745.post@n5.nabble.com>
Content-Type: text/plain; charset=us-ascii
The following is even simpler still:
DO REPEAT elig_group = nov_2010_elig_group TO dec_2011_elig_group
/fpl = nov_2010_fpl TO dec_2011_fpl
/claimable = claimable_nov_2010 TO claimable_dec_2011
/mce_hcci = mce_hcci_nov_2010 TO mce_hcci_dec_2011.
+ COMPUTE elig_group=LTRIM(elig_group).
+ RECODE elig_group ('010', '011'=1)('013','014'=2)('003', '004', '005',
'007', '008'=3) INTO claimable .
+ IF (claimable_elig_group = 1) & sysmis(fpl) fpl = 0.
+ COMPUTE mce_hcci = claimable -(claimable EQ 3) * ((fpl LE 133)+1).
+ RECODE claimable(1,2,3=1).
END REPEAT.
David Marso wrote
>
> I would likely rewrite your syntax as follows:
> DO REPEAT elig_group = nov_2010_elig_group TO dec_2011_elig_group
> /fpl = nov_2010_fpl TO dec_2011_fpl
> /claimable = claimable_nov_2010 TO claimable_dec_2011
> /mce_hcci = mce_hcci_nov_2010 TO mce_hcci_dec_2011.
> + COMPUTE elig_group=LTRIM(elig_group).
> + RECODE elig_group ('010', '011'=1)('013','014'=2)('003', '004', '005',
> '007', '008'=3) INTO claimable .
> + IF (claimable_elig_group = 1) & sysmis(fpl) fpl = 0.
> + COMPUTE mce_hcci = (claimable EQ 1)|((claimable EQ 3) & (fpl LE 133))
> + ((claimable EQ 2)|((claimable EQ 3) & (fpl GT 133)))*2.
> + RECODE claimable(1,2,3=1).
> END REPEAT.
>
>
> David Marso wrote
>>
>> EXECUTE is rarely required!
>> Only situations are SELECT based on $CASENUM and variables computed from
>> LAG.
>> Sometimes not even NECESSARY then, but good in these cases to cover your
>> butt in case you are uncertain.
>>
>> mpirritano wrote
>>>
>>> All,
>>>
>>>
>>>
>>> This syntax appears to be working but I want to be sure it is doing what
>>> I think it's doing.
>>>
>>>
>>>
>>> I'm using do repeat to calculate a value and then using that calculated
>>> value within the do repeat syntax. This is where I get mixed up about
>>> the rules of 'execute'. I would think you'd have to execute the one
>>> statement first before the next statement would have anything to work
>>> with, but I'm not sure if that isn't what is happening already within
>>> the do repeat statement. Is what I'm doing kosher?
>>>
>>>
>>>
>>> Prior to this syntax all of the variables that are listed after my
>>> stand-in variables exist and are in the proper order. Like I said, it
>>> runs fine. Here's my syntax
>>>
>>>
>>>
>>>
>>>
>>> do repeat elig_group = nov_2010_elig_group to dec_2011_elig_group
>>>
>>> /fpl = nov_2010_fpl to dec_2011_fpl
>>>
>>> /claimable = claimable_nov_2010 to claimable_dec_2011
>>>
>>> /mce_hcci = mce_hcci_nov_2010 to mce_hcci_dec_2011.
>>>
>>>
>>>
>>> * THE FOLLOWING COMPUTE STATEMENT CREATES A VARIABLE THAT IS
>>> THEN USED BY THE NEXT 'IF', AND 'DO-IF' STATEMENTS.
>>>
>>> compute claimable = any(ltrim(rtrim(elig_group)), '003', '004', '005',
>>> '007', '008', '010', '011','013', '014').
>>>
>>> if (claimable_elig_group = 1) & (sysmis(fpl) = 1) fpl = 0.
>>>
>>>
>>>
>>> do if (any(ltrim(rtrim(elig_group)), '003', '004', '005', '007',
>>> '008')).
>>>
>>> if (claimable = 1) & (fpl <=133) mce_hcci = 1.
>>>
>>> if (claimable = 1) & (fpl >133) mce_hcci = 2.
>>>
>>> if (claimable = 0) mce_hcci = 3.
>>>
>>> else if (any(ltrim(rtrim(elig_group)), '010', '011')).
>>>
>>> compute mce_hcci = 1.
>>>
>>> else if (any(ltrim(rtrim(elig_group)), '013', '014')).
>>>
>>> compute mce_hcci = 2.
>>>
>>> end if.
>>>
>>> end repeat.
>>>
>>> exe.
>>>
>>>
>>>
>>> Thanks!
>>>
>>> Matt
>>>
>>>
>>>
>>> Matthew Pirritano, Ph.D.
>>>
>>> Research Analyst IV
>>>
>>> Medical Services Initiative (MSI)
>>>
>>> Orange County Health Care Agency
>>>
>>> (714) 568-5648
>>>
>>
>
--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/use-value-computed-in-do-repeat-within-do-repeat-tp5081644p5085027.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
|