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 (September 2000, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 19 Sep 2000 23:48:39 -0400
Reply-To:     Richard DeVenezia <radevenz@IX.NETCOM.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Richard DeVenezia <radevenz@IX.NETCOM.COM>
Organization: MindSpring Enterprises
Subject:      Re: How do I?

James:

Try using the filevar= option of the file statment

If 'another' is not sorted appropriately you need to use mod to ensure file is not whacked when it is reopened for writing; If the data will be processed in order, do not need mod, since file is reopened only when filevar=variable value is different than previous time file statement was reached

dynamic_filename = 'file' || trim(left(put(i,4.))) || '.dat'; file dummy filevar=dynamic_filename mod; put ...

The data will be written to file whose name is stored in variable 'dynamic_filename' (e.g. file1.dat, etc)

-- Richard DeVenezia - try my new SAS Registry Browser under examples SAS Macros and AF Tools - http://pweb.netcom.com/~radevenz "Kerrison, James" <James.Kerrison@FMR.COM> wrote in message news:94131794A239D41198B70008C7918F005DE450@msgmro576nts.fmr.com... > Greetings SAS-Lers, > > It has been a long day, and I am struggling with what seems like a pretty > simple task soooooo.... > > What I want to do is to subset a dataset, and output that subset to a file > multiple times. There are 54 different groups in the specific dataset that I > am working with so in this case I would want to set each subset ( by 1 to > 54), and create 54 different files ( file1.dat, file2.dat, file3.dat....). > > Code would look like this: > > data every ; > set combine ; > by id_num ; > if last id_num then call symput ('nums',id_num); **** assign a macrovar > to the last number ; > > This is where I am losing it. I would think in pseuso code as follows; > > data _null_ ; > set another ; > do i = 1 to &nums ; > if id-nums = i ; ***** this is the subset that I want to work with. > This will/should be different each time ; > file "file(i).dat" on the first iteration, through the last iteration; > ******* increment a filename with each pass - see notes above; > put @ 01 id_num 2. @ 10 name $20. @ 50 balance 15.2 @ 80 rate > percent8.2 ; > end ; > run ; > > The problem is how do I get the filenames to increment? > > TIA, > > Regards, > > Foster Kerrison.


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