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 (February 2006, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 23 Feb 2006 14:38:57 +0000
Reply-To:     toby dunn <tobydunn@HOTMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         toby dunn <tobydunn@HOTMAIL.COM>
Subject:      Re: problem with resolving a macro variable
Comments: To: rune@FASTLANE.NO
In-Reply-To:  <1140686059.497997.153840@o13g2000cwo.googlegroups.com>
Content-Type: text/plain; format=flowed

Rune,

I hope that this is a example. Simply put you are doing three things wrong. First you are %including the SAS code which seems silly to me, it would make more sense to just compile and store the thing that way. Secondly, You havent invoked the macro yet but you are trying to use the macro variable that whould be produced by your macro. Thirdly, this macro var created by your macro if you invoke it will local unless you have already defined the macro as global before you invoke this macro.

And no you dont have to make the dang macro var global at all. That is just a poor understanding of macro language and usage. In your case all you need to do is one rewrite your macro definition to :

%macro create_macro_variables ; %local myname ;

%let myname = Rune ;

&myname %mend ;

And in your program if yo insist on %including the code:

%include "D:\SAS_KODE\utvikling\create_macro_variables.sas" ;

%put The macro variable 'myname' resolves to : %create_macro_variables ;

Toby Dunn

From: Rune Runnestø <rune@FASTLANE.NO> Reply-To: Rune Runnestø <rune@FASTLANE.NO> To: SAS-L@LISTSERV.UGA.EDU Subject: problem with resolving a macro variable Date: Thu, 23 Feb 2006 01:14:19 -0800

Hi, This is how the file CREATE_MACRO_VARIABLES.sas looks like:

%macro create_macro_variables; %let myname = Rune; %mend;

And this is how the file MAIN.sas looks like:

%include "D:\SAS_KODE\utvikling\create_macro_variables.sas";

%put The macro variable 'myname' resolves to : &myname;

This is what the log tells me: %put The macro variable 'myname' resolves to: &myname; WARNING: Apparent symbolic reference MYNAME not resolved. The macro variable 'myname' resolves to: &myname

I have also tried to write %global myname; outside the macro in the the file CREATE_MACRO_VARIABLES.sas, but it doesn't help. Writing %global myname inside the macro didn't help either.

Does this problem have another solution than just omitting to give macro variables values within a macro ?

Regards, Rune


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