Date: Tue, 10 May 2005 16:06:43 -0400
Reply-To: joewhitehurst@bellsouth.net
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Joe Whitehurst <joewhitehurst@BELLSOUTH.NET>
Organization: Analyticum, Inc.
Subject: Re: Macro loop using datevalues
In-Reply-To: <42810589.6050807@DataSavantConsulting.com>
Content-Type: text/plain; charset="us-ascii"
Au Contraire Greg. Unless you compile your data step and incur the added
burden of keeping track of both the compiled version and the source code,
the data step will be compiled before execution every time you run it. And
I have to ask if you really think call execute is simpler than submit
endsubmit?
Both-tongues-in-cheek regards,
Joe
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Gregg
Snell
Sent: Tuesday, May 10, 2005 3:04 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: Macro loop using datevalues
Noel,
You could follow the accurate if tortuous advice offered by SCL
knowledgeable expert posters, or, you could save yourself a lot of grief by
using the DATA Step with "call execute" for tasks that you think require SCL
and by forgetting about the SAS Component Language. You have nothing
to lose with respect to functionality and a lot of clarity and ease of
coding to gain. Using DATA Step with "call execute", your example would
look like
this:
data _null_;
dte1='1-May-2004'd;
dte2='10-Jul-2004'd;
do i=dte1 to dte2; /* (1 day is the default increment)*/
put i=; /*This will be a SAS date value.*/
call execute('data temp;set temp; where temp = ' || put(i,best.)
|| ';run;'); /*no macro variables here either!*/
end;
run;
And no need to compile before execution! :-)
Tounge-in-cheek regards,
Gregg Snell
Joe Whitehurst wrote:
>Noel,
>
>You could follow the accurate if tortuous advice offered by macro
>knowledgeable expert posters, or, you could save yourself a lot of grief by
>using SAS Component Language for tasks that you think require SAS Macro
>Language and by forgetting about the SAS Macro Language. You have nothing
>to lose with respect to functionality and a lot of clarity and ease of
>coding to gain. Using SAS Component Language, your example would look like
>this:
>Init:
> dte1='1-May-2004'd;
> dte2='10-Jul-2004'd;
> do i=dte1 to dte2; /* (1 day is the default increment)*/
>
> put i; /*This will be a SAS date value.*/
> submit continue:
> data temp;set temp; where temp = &i;run; /*&I is NOT a macro
>variable*/
> endsubmit;
> end;
>return;
>
>
>-----Original Message-----
>From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Noel
>O'Sullivan
>Sent: Tuesday, May 10, 2005 5:54 AM
>To: SAS-L@LISTSERV.UGA.EDU
>Subject: Macro loop using datevalues
>
>
>I have just started using macro processing and have been using basic loops.
>
>However, I would like to use dates in loops, for example:
>
><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office"
/>
>
>%macro test;
>
>%let dte1 = '1-May-2004'd;
>
>%let dte2 = '10-Jul-2004'd;
>
> %do i = &dte1 %to &dte2;
>
> %put &i;
>
> data temp;set temp; where temp = &i;run;
>
> %end;
>
>%mend;
>
>%test;
>
>
>
>The loop only seems to work from numbers. Do I have to transform the date
to
>a number and then back again to use the date.
>
>
>
>TIA
>
>
>
>
|