DATA Step, Macro, Functions and more

How to change the value stored in the macro variable change dynamically based on a condition?

Accepted Solution Solved
Reply
New Contributor
Posts: 2
Accepted Solution

How to change the value stored in the macro variable change dynamically based on a condition?

[ Edited ]

Hello Guys,

 

I have a dataset with a variable called "ENVIRONMENT", the values will in it would be either "UAT" or "PROD", but not both the values.

 

I want to store the value in a macro variable.

 

eg. if the dataset has a value of "UAT" stored today the macro variable should resolve to "UAT".

if the next extract of dataset tomorrow contains "PROD" i want the macro variable to resolve to "PROD"

 

Can anyone please help me out?

 

 

 

 

 

 

 


Accepted Solutions
Solution
‎03-10-2018 06:08 AM
Super User
Posts: 9,880

Re: How to change the value stored in the macro variable change dynamically based on a condition?

Posted in reply to rajuganesh30

Something like

data _null_;
set have (obs=1);
call symputx('macrovar',environment);
run;

?

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code

View solution in original post


All Replies
Solution
‎03-10-2018 06:08 AM
Super User
Posts: 9,880

Re: How to change the value stored in the macro variable change dynamically based on a condition?

Posted in reply to rajuganesh30

Something like

data _null_;
set have (obs=1);
call symputx('macrovar',environment);
run;

?

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
New Contributor
Posts: 2

Re: How to change the value stored in the macro variable change dynamically based on a condition?

Posted in reply to KurtBremser
Thanks for the Answer
Occasional Contributor
Posts: 9

Re: How to change the value stored in the macro variable change dynamically based on a condition?

Posted in reply to rajuganesh30

@rajuganesh30-

is there anything in your dataset which can trigger extraction or Data refresh is happening for UAT Or PROD environment?

If yes then we can change macro variables value dynamically o.w we need to pass macro parameters 

☑ This topic is solved.

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

Discussion stats
  • 3 replies
  • 126 views
  • 0 likes
  • 3 in conversation