Help using Base SAS procedures

SAS Macro Problem - Please Help

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 9
Accepted Solution

SAS Macro Problem - Please Help

Hi All,

I need the following output

num2 = Code493736

where, num = 493736.

I am using the following code but I am not any value in num2.

%let num=493736;

%macro see1();

data _null_;

%if %length(&num.)>4 %then %do;

%let num1 = %cmpres(&num.);

%let num2 = Code&num1.;

%end;

run;

%mend;

%see1();

%put &num2.;

Thanks

Pihu


Accepted Solutions
Solution
‎07-26-2013 02:14 PM
Super Contributor
Posts: 339

Re: SAS Macro Problem - Please Help

add a

%GLOBAL num2;

statement inside your macro

macro variables created within a macro are local to that macro. However, you could've also swapped your %put &num2.; statement inside the macro for the same result. That is, the macro worked fine you just did not consider the scope of the variable for your intended purpose.

Vincent

View solution in original post


All Replies
Solution
‎07-26-2013 02:14 PM
Super Contributor
Posts: 339

Re: SAS Macro Problem - Please Help

add a

%GLOBAL num2;

statement inside your macro

macro variables created within a macro are local to that macro. However, you could've also swapped your %put &num2.; statement inside the macro for the same result. That is, the macro worked fine you just did not consider the scope of the variable for your intended purpose.

Vincent

Occasional Contributor
Posts: 9

Re: SAS Macro Problem - Please Help

Posted in reply to Vince28_Statcan

Thanks a ton!

It works now Smiley Happy

🔒 This topic is solved and locked.

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

Discussion stats
  • 2 replies
  • 150 views
  • 1 like
  • 2 in conversation