Date: Fri, 10 Aug 2007 11:38:51 -0400
Reply-To: "Fehd, Ronald J. (CDC/CCHIS/NCPHI)" <rjf2@CDC.GOV>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Fehd, Ronald J. (CDC/CCHIS/NCPHI)" <rjf2@CDC.GOV>
Subject: Re: Iterative Processing Issues
In-Reply-To: <200708101508.l7AF2f1X002444@mailgw.cc.uga.edu>
Content-Type: text/plain; charset=us-ascii
replace this
> do i=1 to i=12 until (enrollyear{i}=outyear);
with this:
do i=1 to dim(enrollyear) until (enrollyear{i}=outyear);
you probably want to check and initialize outyear before you enter the
loop
Ron Fehd the macro maven CDC Atlanta GA USA RJF2 at cdc dot gov
see also:
DO Which? Loop, UNTIL, or WHILE?
A Review of DATA Step and Macro Algorithms
http://www2.sas.com/proceedings/forum2007/067-2007.pdf
> -----Original Message-----
> From: owner-sas-l@listserv.uga.edu
> [mailto:owner-sas-l@listserv.uga.edu] On Behalf Of E Henderson
> Sent: Friday, August 10, 2007 11:09 AM
> To: SAS-L@LISTSERV.UGA.EDU
> Cc: E Henderson
> Subject: Iterative Processing Issues
>
> I'm trying to run the following code, but every time I
> execute it, I the values of the variable I'm trying to create
> (gradstem) remain exactly the same. Any guidance would be
> appreciated.
>
> data nlsy79_stemtrans_v3_ba;
>
> set nlsy79_stemtrans_v2_ba;
>
> array enrollyear{12} enrollyear1-enrollyear12;
>
> array enrolltype{12} enrolltype1-enrolltype12;
>
> array attstat{12} attstat1-attstat12;
>
> array majorcat{12} majorcat1-majorcat12;
>
> /*
>
> array jobord{13} jobord1-jobord13;
>
> array currstat{13} currstat1-currstat13;
>
> array hoursjob{13} hoursjob1-hoursjob13;
>
> array yearearn{13} yearearn1-yearearn13;
>
> array occcatjob{13} occcatjob1-occcatjob13;
>
> */
>
> gradstem=0;
>
> do i=1 to i=12 until (enrollyear{i}=outyear);
>
> if attstat{i}=1 then do;
>
> if 1<=(majorcat{i})<=4 and (enrolltype{i})=1 then
> gradstem=1;/*Grad FT STEM*/
>
> else if 5<=(majorcat{i})<=9 and (enrolltype{i})=1 then
> gradstem=2;/*Grad FT Non STEM*/
>
> else if 1<=(majorcat{i})<=4 and (enrolltype{i})=2 then
> gradstem=3;/*Other FT STEM*/
>
> else if 5<=(majorcat{i})<=9 and (enrolltype{i})=2 then
> gradstem=4;/*Other FT Non STEM*/
>
> end;
>
> end;
>
> drop i;
>
> run;
>
>
|