BookmarkSubscribeRSS Feed
RTelang
Fluorite | Level 6

%let test1=30;

%macro test(ds=abs,a=10,b=20);

data &ds; a=&a; b=&b;

%put _local_; run;

%mend;

options symbolgen mprint;

 %test(ds=abs,a=10,b=20)

 

 

i did this to display local variable to the log bot test1=30 is not displayed plz retify my mistake.

6 REPLIES 6
SJN
Fluorite | Level 6 SJN
Fluorite | Level 6

Hi Teland,

 

{Code}

%macro ;

-----------

%put _local_;

%mend;

If you understand the _local_. Its displays/works only the macro variables which are present inside the macro.

 

{Code}

%let a=10;

%macro ;

-----------

%put _Global_; or %put _user_;

%mend;

 

if you want to diaplay the macro variables outside the macro which are present (Global macros variables) you need to use _global_;

 

Hope this helps you if you still dont understand let me know.

 

RW9
Diamond | Level 26 RW9
Diamond | Level 26
Astounding
PROC Star

Unfortunately, the change needs to occur in your expectations not in the code itself.  This statement appears outside of the macro definition:

 

%let test1=30;

 

Therefore, &TEST1 is a global macro variable, and won't appear in the list of %LOCAL macro variables.

RTelang
Fluorite | Level 6

%let a=10 b=12 c=15;
%macro test(varlist=a b c test1);
string=(varlist= a b c test1);
%do varlist=&a %to test1;

%put _local_ ;
%end;
%mend test;
options symbolgen mprint;
%test

 

will this work or retify it!

i want to display varlist= a b c test1 to the log with their values

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Still duplicate, please don't have two posts for the same question.

RTelang
Fluorite | Level 6
i am sending d code as i am updating it need i ur help to rectify my mistake plz do help

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 1250 views
  • 0 likes
  • 4 in conversation