LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (August 2005, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
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
In-Reply-To:  <MC8-F5lb32su1lS1REM001a7136@MC8-F5.hotmail.com>
Content-Type: text/plain; format=flowed

Alex.Gould@STANFORD.EDU wrote: >Quick question for you all... I have created the following macro for >some time series data: > >%macro dodates1; > %do i=1 %to 1000; > if n=&i then do; > price&i=prc; > date&i=date; > %end; >%mend; > >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, >'myfile.txt' with: > >%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 shapes.

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.

HTH, David -- David L. Cassell mathematical statistician Design Pathways 3115 NW Norwood Pl. Corvallis OR 97330

_________________________________________________________________ Don’t just search. Find. Check out the new MSN Search! http://search.msn.click-url.com/go/onm00200636ave/direct/01/


Back to: Top of message | Previous page | Main SAS-L page