Date: Sun, 11 May 1997 20:12:13 +0100
Reply-To: Peter Crawford <Peter@CRAWFORDSOFTWARE.DEMON.CO.UK>
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: Peter Crawford <Peter@CRAWFORDSOFTWARE.DEMON.CO.UK>
Subject: Re: Counting w/ Macro Variable
In article <01BC5C5E.8E7D2A60@jpjwnt1.hsc.usc.edu>, Jason Jones
<jasonj@RCF.USC.EDU> writes
>Hi All,
> I need a way to use a macro variable as the counting variable in a DO
>loop (or some way to pass the value of the counting variable to the macro
>variable) so that the value can be used in the DO loop processing. SYMPUT
won't
>work because the value only gets passed after the DATA step is complete. I
can
>define the variable and give it a single value with a %LET statement, but I'm
>not able to find a way to then increment this value with each iteration of the
>DO loop.
> The reason I want to do this (in case someone comes up with a superior
>method) is because I have a dataset that has multiple lines of data for each
>observation. This would be fine except that each observation has a different
>number of variables and, therefore, a different number of lines. I can't just
>create variables for the highest number of variables/lines, because the
>observations follow one after the other and I'll be reading into the next
>observations lines.
> What I would like to write is something like:
>DATA work.aluin;
> INFILE "d:\data files\consult\pjones\imports\alutest.txt"
> MISSOVER;
> INPUT @1 (test1) ($6.) @;
> IF test1="Primin" THEN DO;
> INPUT #1 @8 (tp&ln._1-tp&ln._4) ($1.)
> // @1 (gene1) ($6.)
> @8 (th&ln._1-th&ln._4) ($1.)
> //// @1 (test2) ($6.)
> // @1 (gene2) ($6.) @;
> IF gene1^=gene2 THEN %LET ln=1;
> ELSE %LET ln=i+1;
> OUTPUT;
> END;
>RUN;
>
>This won't work, but perhaps it gives you enough of an idea of what I'm trying
>to do.
>
> Jason
>
>Jason Jones
>Dept. of Pharmaceutical Economics & Policy
>USC
Jason
Perhaps you should look at using an ordinary numeric variable
as an array subscript inside a DO WHILE loop, instead of using
a macro variable suffix.
Surely macro variables need to be resolved at compile time,
which means before the step executes the %let statement even
for the first time.
Good luck
--
Peter Crawford Peter@crawfordsoftware.demon.co.uk
|