DATA Step, Macro, Functions and more

macro quoting at macro parameter value

Accepted Solution Solved
Reply
Contributor
Posts: 62
Accepted Solution

macro quoting at macro parameter value

Hello,

When I create a macro parameter procedure, can a macro value be refered?

For example,

%let report=Monthly;
%let infile=monthly_TestReport_2017-9.xlsx;

 

%ReadXlsbd (inf=&infile., title=&report.);

when I do that, it does not work. Is possible anyway to solve that problem.

 

Thanks a lot,

 

 

 


Accepted Solutions
Solution
‎10-11-2017 11:04 AM
Super User
Posts: 11,343

Re: macro quoting at macro parameter value


daisy6 wrote:

Hello,

When I create a macro parameter procedure, can a macro value be refered?

For example,

%let report=Monthly;
%let infile=monthly_TestReport_2017-9.xlsx;

 

%ReadXlsbd (inf=&infile., title=&report.);

when I do that, it does not work. Is possible anyway to solve that problem.

 


By any chance are you attempting to use the macro variable Report to place the text "Monthly" into the text of the Infile macro variable?

That would be

%let infile=&report._TestReport_2017-9.xlsx;

 

It really helps to show what you think you want to build given pieces as we are having to make lots of guesses.

 

View solution in original post


All Replies
Frequent Contributor
Posts: 149

Re: macro quoting at macro parameter value

Not working? Post log with mprint and symbolgen active. I don't see a reason for not working.
Super User
Posts: 19,855

Re: macro quoting at macro parameter value


daisy6 wrote:

 

when I do that, it does not work. 

 


What does 'not work' mean? 
Post your full code and log. 

 

Please use MPRINT and SYMBOLGEN to make sure the log has all the macro information. 

 

Basically, this works, so you're doing something wrong but you haven't provided enough information for us to tell you what it is.

 

%let test=one;
%let random = two;

%macro demo(var=);

%put "Macro Variable is " &var.;

%mend;

%demo(var=&test.);
%demo(var=&random.);

 

 

Contributor
Posts: 62

Re: macro quoting at macro parameter value

I test my code again, and it works this time.

Contributor
Posts: 62

Re: macro quoting at macro parameter value

Thanks for reply!

Respected Advisor
Posts: 4,173

Re: macro quoting at macro parameter value

@daisy6

If using SAS EG or SAS Studio then make sure that your final test is done AFTER you've closed and re-opened your SAS session. This is to avoid that some "left-overs" allow you to run code which actually doesn't work in a fresh session. 

Solution
‎10-11-2017 11:04 AM
Super User
Posts: 11,343

Re: macro quoting at macro parameter value


daisy6 wrote:

Hello,

When I create a macro parameter procedure, can a macro value be refered?

For example,

%let report=Monthly;
%let infile=monthly_TestReport_2017-9.xlsx;

 

%ReadXlsbd (inf=&infile., title=&report.);

when I do that, it does not work. Is possible anyway to solve that problem.

 


By any chance are you attempting to use the macro variable Report to place the text "Monthly" into the text of the Infile macro variable?

That would be

%let infile=&report._TestReport_2017-9.xlsx;

 

It really helps to show what you think you want to build given pieces as we are having to make lots of guesses.

 

Contributor
Posts: 62

Re: macro quoting at macro parameter value

Thank you for reply. Ballardw

☑ This topic is solved.

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

Discussion stats
  • 7 replies
  • 121 views
  • 0 likes
  • 5 in conversation