- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
If the macro variable DSN resolves to 'FACTOR' then I want the macro variable NAME to resolve it as 'AMM' otherwise I want to resolve it how it resolves earlier.
Macro variable NAME is being resolved based on some logic and I want to overwrite that logic only if the value of other macro variable DSN resolves to 'FACTOR'.
Appericiate if someone of you shed some light on this.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Not sure if you're using macro code or data step code.
If you're using macro code then you could try something like the following then check the log for the results:
/* macro method */
%macro set_name;
%if &dsn eq FACTOR %then
%let name = AMM;
%mend set_name;
%let dsn = ABC;
%let name = XYZ;
%set_name;
%put name = &name;
%let dsn = FACTOR;
%set_name;
%put name = &name;If you're using data step code then the following should also work:
/* data step method */
data _null_;
if "&dsn" eq 'FACTOR' then
call symputx('name','AMM');
run;
Kind regards,
Amir.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi @David_Billa
I have tried this. Let me know!
Best,
options mlogic;
/* Initialization */
%let NAME = initial_value;
%let DSN = FACTOR;
%put &NAME &DSN;
/* Conditional execution*/
%macro mv();
%if "&DSN" = "FACTOR" %then %do;
data _null_;
call symputx("NAME","AMM");
run;
%end;
%mend;
%mv;
/* Result */
%put &NAME &DSN;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Not sure if you're using macro code or data step code.
If you're using macro code then you could try something like the following then check the log for the results:
/* macro method */
%macro set_name;
%if &dsn eq FACTOR %then
%let name = AMM;
%mend set_name;
%let dsn = ABC;
%let name = XYZ;
%set_name;
%put name = &name;
%let dsn = FACTOR;
%set_name;
%put name = &name;If you're using data step code then the following should also work:
/* data step method */
data _null_;
if "&dsn" eq 'FACTOR' then
call symputx('name','AMM');
run;
Kind regards,
Amir.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@David_Billa wrote:
If the macro variable DSN resolves to 'FACTOR' then I want the macro variable NAME to resolve it as 'AMM' otherwise I want to resolve it how it resolves earlier.
Macro variable NAME is being resolved based on some logic and I want to overwrite that logic only if the value of other macro variable DSN resolves to 'FACTOR'.
Appericiate if someone of you shed some light on this.
%if &dsn=FACTOR %then %let name=ANN;
Please note that macro variable values do not have quotes around them, and are case sensitive.
Paige Miller