BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Ronein
Meteorite | Level 14

Hello

user enter branch number in a macro var.

The task is to create a new macro var that will get value 1 or 0.

If branch=876  then the macro var will get value 1 ,else  value 0.

What is the way to do it please?

 


%let branch=876;
/*****%let branch=982;*******/
%macro Binary_Macro_Var;
%if &branch.=876 %then %do; 
%let Ind876=1;
%end; 
%else %do;
Ind876=0;
%end;
%mend Binary_Macro_Var; 
%Binary_Macro_Var
%put &Ind876.;
1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

The macro variable &IND876 that you create inside the macro is available ONLY inside the macro.

 

You can fix this by using a %GLOBAL statement inside the macro, or better yet just not doing this inside a macro.

 

%let ind876 = %eval(&branch=876);

  

--
Paige Miller

View solution in original post

1 REPLY 1
PaigeMiller
Diamond | Level 26

The macro variable &IND876 that you create inside the macro is available ONLY inside the macro.

 

You can fix this by using a %GLOBAL statement inside the macro, or better yet just not doing this inside a macro.

 

%let ind876 = %eval(&branch=876);

  

--
Paige Miller

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 1 reply
  • 106 views
  • 1 like
  • 2 in conversation