| Date: | Fri, 9 Feb 2007 03:10:48 -0500 |
| Reply-To: | Jim Groeneveld <jim2stat@YAHOO.CO.UK> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | Jim Groeneveld <jim2stat@YAHOO.CO.UK> |
| Subject: | Re: Formatting a macro variable |
|
Hi Dale,
See also my macro PreZeros with some additional capabilities
http://home.hccnet.nl/jim.groeneveld/software/SASmacro/PreZeros.zip
Regards - Jim.
--
Jim Groeneveld, Netherlands
Statistician, SAS consultant
home.hccnet.nl/jim.groeneveld
On Thu, 8 Feb 2007 21:44:54 -0800, Dale McLerran <stringplayer_2@YAHOO.COM>
wrote:
>Art,
>
>Precisely! I knew it was simple, but I just couldn't come up
>with the putn function.
>
>Thanks,
>
>Dale
>
>--- Arthur Tabachneck <art297@NETSCAPE.NET> wrote:
>
>> Dale,
>>
>> Couldn't you just use something like:
>>
>> %let ii=%sysfunc(putn(&I,z3.));
>> test_&ii._1 test_&ii._2
>>
>> HTH,
>> Art
>> ----------
>> On Thu, 8 Feb 2007 17:33:29 -0800, Dale McLerran
>> <stringplayer_2@YAHOO.COM> wrote:
>>
>> >Hi all,
>> >
>> >I know that this should be simple, but I can't recall how it is
>> >done. Suppose that there is an ascii file with two columns of
>> >replicate information from 287 subjects. These 574 variables
>> >should be read into a data set with names:
>> >
>> > test_001_1 test_001_2 test_002_1 test_002_2 ... test_287_2
>> >
>> >Now, I can use a macro loop something like the following:
>> >
>> > input %do i=1 %to 287;
>> > test_&i._1 test_&i._2
>> > %end;;
>> >
>> >But this does not quite work. I need to format the index variable
>> >using a Z3. format so that when &i=1, then the macro code
>> >evaluates to 001, etc. What do I need to express a formatted
>> >value in place of the reference to macro variable i?
>> >
>> >I can use a kludge where I construct a macro variable j as 00&i
>> >if &i<10 and as 0&i if 10<=&i<100. I could then reference macro
>> >variable j instead of macro variable i. But I would prefer to
>> >use a format to construct the correct reference if I can.
>> >
>> >Thanks,
>> >
>> >Dale
|