Date: Fri, 8 May 2009 18:13:33 -0400
Reply-To: Arthur Tabachneck <art297@NETSCAPE.NET>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Arthur Tabachneck <art297@NETSCAPE.NET>
Subject: Re: sasautos: Store multiple macros
Dan,
Take a look at: analytics.ncsu.edu/sesug/2005/AD07_05.PDF
Especially, the last section of the paper which talks about the stored
macro facility.
Art
---------
On Fri, 8 May 2009 17:43:35 -0400, SUBSCRIBE SAS-L Dan
<deniseyu001@GMAIL.COM> wrote:
>Hi. SasLers:
>
>Please help with following:
>
>I have a macro with name %country_code, it is saved as country_code.sas
>under the location "C:\Documents and Settings\linl\Desktop\loc1"
>
>country_code.sas is as following:
>
>%macro country_code ;
> length cou1a $3 ;
> if 1001 <= input(substr(pt,1,4), 8.) <= 1009 then cou1a = "USA" ;
> else if 2001 <= input(substr(pt,1,4), 8.) <= 2004 then cou1a = "BEL" ;
> else if 4001 <= input(substr(pt,1,4), 8.) <= 4003 then cou1a = "HUN"
;
> else if 5001 <= input(substr(pt,1,4), 8.) <= 5003 then cou1a = "POL"
;
> else if 7001 <= input(substr(pt,1,4), 8.) <= 7002 then cou1a
>= "BRA" ;
>%mend ;
>
>I have another program as following:
>
>filename winloc 'C:\Documents and Settings\linl\Desktop\loc1' ;
>
>options sasautos=(winloc, sasautos);
>
>options symbolgen mprint ;
>
>data dt1 ;
> pt='1003' ;
> x=1 ;
> %country_code;
> put _all_ ;
>run;
>
>When I run the program, everything is fine. A typical textbook example.
>
>However, I want to put into country_code.sas many macros, like
>
>%macro a1 ;
>
> *more statements ;
>%mend a1 ;
>
>%macro a2 ;
>
> *more statements ;
>%mend a2 ;
>
>And then I want to call the macros by the following program:
>
>
>filename winloc 'C:\Documents and Settings\linl\Desktop\loc1' ;
>
>options sasautos=(winloc, sasautos);
>
>options symbolgen mprint ;
>
>data dt1 ;
> pt='1003' ;
> x=1 ;
> %a1;
> %a2;
> put _all_ ;
>run;
>
>Apparently it will not work because the macro name has to be the same as
>the macro program saved.
>
>Any ideas?
>
>Thanks.
>
>Dan
|