LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (August 2001, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Mon, 27 Aug 2001 10:52:57 -0700
Reply-To:   "Terjeson, Mark" <TerjeMW@DSHS.WA.GOV>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "Terjeson, Mark" <TerjeMW@DSHS.WA.GOV>
Subject:   Re: Macros and global variables
Comments:   To: "Draschner, Eugenio A" <eugenio.draschner@OTS.TREAS.GOV>
Content-Type:   text/plain; charset=us-ascii

Hi Eugenio,

Here are two methods. First, utilizing the CALL SYMPUT() function to get your datastep working, along with matching up variable type conversions a little bit, try this first example. Secondly, for those who like to trim down to smaller code a second example using a %LET and a %SYSFUNC() is provided in the second example. (These examples tend to take your sample of using fixed literal date values, if these are more dynamic, you will have to expand from here.)

%macro name(macname); data _null_; month = 06; year = 2001; day = 30; x = mdy(month,day,year); call symput("&macname",put(x,8.)); run; %mend;

%name(y)

%put &y;

%macro name(macname); %global &macname; %let &macname=%sysfunc(mdy(6,30,2001)); %mend;

%name(yy)

%put yy is >&yy<;

Hope this is helpful, Mark Terjeson Washington State Department of Social and Health Services Division of Research and Data Analysis (RDA) mailto:terjemw@dshs.wa.gov

-----Original Message----- From: Draschner, Eugenio A [mailto:eugenio.draschner@OTS.TREAS.GOV] Sent: Monday, August 27, 2001 9:39 AM To: SAS-L@LISTSERV.UGA.EDU Subject: Macros and global variables

Wondering if any one of you could help with the following macro problem.

I have a macro which I want to use to create a global macro variable. I want the name of this variable to be passed to the macro. I then want the macro to assign a SAS date value to that global variable. I have the following code, but I am not getting what I want. The local variable x has the value (15156) I am trying to pass to the global variable (y), but the y variable ends up with 'x' as a value. Any help would be most appreciated.

Regards to all.

%macro name(macname); data _null_; month = '06'; year = '2001'; day = '30'; x = mdy(trim(month),trim(day),trim(year)); %global &macname; &macname = x; put &macname; run; %mend;

%name(y)

%put &y;


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