DATA Step, Macro, Functions and more

Convert local to global macro vice versa used %global

Accepted Solution Solved
Reply
Contributor
Posts: 66
Accepted Solution

Convert local to global macro vice versa used %global


I wnat to convert the local to gloabl and global to local macro variables
can any one help me with some examples

in the above i have tryed like this

%macro a;
%let loc=10;
%put &loc;
%mend;

%a;

%global &loc;

Tryed

%global loc;

%put &loc;

it should reove to 10 but it was not resloving


Accepted Solutions
Solution
‎12-26-2011 04:35 AM
Super User
Posts: 10,018

Convert local to global macro vice versa used %global

LOCAL  --> GLOBAL

%macro a;
%global global_loc;

%let loc=10;
%let global_loc=&loc;
%mend;

%a

%put &global_loc;






Ksharp

View solution in original post


All Replies
Solution
‎12-26-2011 04:35 AM
Super User
Posts: 10,018

Convert local to global macro vice versa used %global

LOCAL  --> GLOBAL

%macro a;
%global global_loc;

%let loc=10;
%let global_loc=&loc;
%mend;

%a

%put &global_loc;






Ksharp

Contributor
Posts: 66

Convert local to global macro vice versa used %global

small query is there any thing that we can convert global to local macros

Super User
Posts: 10,018

Convert local to global macro vice versa used %global

Sure. You can't force global macro variable to be local, but you can pass the value of gloale to local.

%global global_loc;
%let global_loc=Merry_Christmas;


%macro a;
%let loc=&global_loc;
%put &loc;
%mend;

%a




Ksharp

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 1032 views
  • 0 likes
  • 2 in conversation