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 (May 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, 10 May 2005 18:16:29 -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
Comments: To: Gregg Snell <gsnell@DATASAVANTCONSULTING.COM>
In-Reply-To:  <42811AE9.4090801@DataSavantConsulting.com>
Content-Type: text/plain; charset="us-ascii"

Greg,

I think your view is short sighted at best. I would hope that the bright folks participating in this forum are not just offering solutions for given posted problems by members who are clearly relatively inexperienced but, instead, are taking a long view and giving advice that may alter the course of the experience these now inexperienced members have for the better. Because SAS Component language is much more like data step programming (same functions, same naming conventions, much the same syntax, etc) than is the SAS Macro Language, I think there are good reasons to believe that persons experienced with data step programming will find SAS Component Language significantly easier to master than the SAS Macro Language for tasks that can be done with either (we wouldn't want to overburden the poor macro facility with demands involving user interfaces, etc.). This question can be answered empirically. All we need is a few sets of matched newbys randomly assigned to different treatments....

Joe

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Gregg Snell Sent: Tuesday, May 10, 2005 4:35 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: Macro loop using datevalues

Joe,

Given where Noel's knowledge level *appears* to be with respect to 'call execute'/Macro/SCL, which of our solutions do you think would be easier to learn and why? I would argue that 'call execute' would be much simpler as it is merely a new function of the DATA Step which, the example suggests, he already knows.

Regards,

Gregg Snell

Gregg Snell wrote:

> I think call execute is simpler than 'init: .... submit; ... > endsubmit; return;' which must be saved as a catalog entry, > *explicitly* compiled and awkwardly invoked. > > Joe Whitehurst wrote: > >> 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 >>> >>> >>> >>> >>> >> >> >> >> >> >


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