Date: Tue, 9 Aug 2005 16:23:32 -0700
Reply-To: David L Cassell <davidlcassell@MSN.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: David L Cassell <davidlcassell@MSN.COM>
Subject: Re: ranges in MACRO data and PROC steps
Content-Type: text/plain; format=flowed
>Quick question for you all... I have created the following macro for
>some time series data:
> %do i=1 %to 1000;
> if n=&i then do;
>Then, if I have defined this beforehand, I can just type %dodates1;
>inside my data step to generate 3000 lines of if-then-do code.
>My question is how I would alter this macro to account for much
>narrower ranges of "i". I don't need i=1 to 1000. Only things like
>i=1 through 7, and 14 through 22, and 101 throusgh 129 or whatever.
>Any thoughts on how to code that.
>Same goes in the proc summary step. I have created a text file,
>%let prices = "price1 price2 ... price 50000";
>%let dates = "date1 date2 ... date 50000";
>And I would just type %include myfile.txt in the program early on,
>and later on in the proc summary step, I can always just type
>&prices or &dates and have the easier substitution.
>But the same question remains... how to account for ranges.
I'm not completely sure what you need, but I really don't think
a macro is the solution. Not to mention that there are limits on
the size of strings that you can work with conveniently, and
50,000 values in a string may push you over that.
If you have a string of prices or dates in a text file, it seems to
me that you would be *much* better off reading them in using
SAS data step features and assigning the information appropriately
as you read in the entries. A data step can take a string of
values that are in one row and write them out as separate
records for you. Or as a stream of variables in one record,
if you prefer. And you can use PROC TRANSPOSE to switch back
and forth between long-and-thin and short-and-fat data table
Let me just add that some of what you seem to be after might
also be easier using PROC EXPAND in the SAS/ETS module.
But that's just a guess on my part.
Still, I'd look around for a non-macro soluyion first. Perhaps if you
wrote back to SAS-L and explained more fully what you're trying
to do, the gurus around here would be able to come up with a
straightforward solution. Or twelve.
David L. Cassell
3115 NW Norwood Pl.
Corvallis OR 97330
Donít just search. Find. Check out the new MSN Search!