Date: Wed, 31 May 2006 16:36:51 -0400
Reply-To: "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM>
Subject: Re: macro fand filename
On Wed, 31 May 2006 08:06:05 -0700, skyline <carf4F@GMAIL.COM> wrote:
>Is there any way to do this without using macro?
If "this" means dividing up a data set into a bunch of smaller data sets,
each corresponding to a calendar month, then yes, there is a way to do it
without a macro.
But I'm suggesting that you don't do it at all.
Why do you want the separate one-month data sets? The chances are that
whatever you plan to do with them can be accomplished more simply without
the repackaging.
>
>"Howard Schreier <hs AT dc-sug DOT org>" wrote:
>> On Wed, 31 May 2006 06:49:23 -0400, Gerhard Hellriegel <ghellrieg@T-
>> ONLINE.DE> wrote:
>>
>> >no, thats totally wrong. First is, you try to use statements in open
code,
>> >which are only possible IN datasteps.
>> >Second: you cannot use datastep variables in the name of a output
dataset.
>>
>> Third. Creating a lot of small data sets is usually a bad idea. Instead,
>> leave the data in one large data set and use BY and/or WHERE processing
to
>> stratify and/or segregate. Perhaps create an index to speed things up.
>>
>> >One of some possible solutions for that what you want is a macro:
>> >
>> >%macro x;
>> > %let no_years=0;
>> > %let no_months;
>> > data _null_;
>> > set temp.ff1;
>> > ...
>> >
>> >here you should calculate the month and years and write them to macro
>> >variables like:
>> > no_years+1;
>> > call symput("no_years",no_years);
>> > call symput("y"!!compress(put(no_years,8.)),?????); dont know where
your
>> >year comes from... something like year(date) ?
>> > ....
>> > also the months...
>> >
>> >all in all its not clear to me, wher you get the yyyymm from. In my
>> opinion
>> >you should use a SAS-date variable as start, norm all months to the 1st
>> >of... and count the start to end by INTNX("month",...)
>> >
>> >The names you can generate by put(year(dates),z4.) and same for months.
>> >
>> >that you use in a
>> >
>> >data
>> >%do i=&start %to &end;
>> > &&name&i;
>> >%end;
>> > ;
>> > set...;
>> > %do i=1 &start %to &end;
>> > if datum=&&xxxxx&i then output &&name&i;
>> > %end;
>> >run;
>> >%mend;
>> >%x;
>> >
>> >the logic you need, you must fill in.
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >On Wed, 31 May 2006 00:07:09 -0700, skyline <carf4F@GMAIL.COM> wrote:
>> >
>> >>Hello,
>> >>
>> >>I would like to do the following and I would like to know whether it
is
>> >>the correct thing to do;
>> >>
>> >>do myear=begyear to endyear;
>> >>do mmonth=begmon to endmon;
>> >>data temp.perms-myear-mmonth;
>> >>set temp.ff1;
>> >>if yyyymm eq myear*100+mmonth;
>> >>if okdec=1;
>> >>keep permno;
>> >>run;
>> >>end;
>> >>end;
>> >>
>> >>Here I try to create files with the name perms-myear-mmonth for each
>> >>value of myear and mmonth.
>> >>
>> >>Is the above code correct? If not, what is the correct one?
>> >>
>> >>Best regards,
|