DATA Step, Macro, Functions and more

A beginner's question about the macro variable

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 14
Accepted Solution

A beginner's question about the macro variable

Hi all, I wanted to write the string 'the input value is xxx' in the SAS log, using the following macro. My question is why the following does not work and how can I fix it.

%macro test(num=5);

data;

put 'the input value is &num';

/* alternatively I can use an addtional variable to get the desired result*/

a=#

put 'the input value is ' a;

/*but why the first attempt using  '&num ' does not work?*/

%mend test;

%test()


Accepted Solutions
Solution
‎08-24-2013 09:16 AM
PROC Star
Posts: 7,363

Re: A beginner's question about the macro variable

Macro variables, if contained in quotes, won't resolve unless they are enclosed in double (i.e., ") quotes.

View solution in original post


All Replies
Solution
‎08-24-2013 09:16 AM
PROC Star
Posts: 7,363

Re: A beginner's question about the macro variable

Macro variables, if contained in quotes, won't resolve unless they are enclosed in double (i.e., ") quotes.

Occasional Contributor
Posts: 14

Re: A beginner's question about the macro variable

Thanks for the hint.

☑ This topic is SOLVED.

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

Discussion stats
  • 2 replies
  • 184 views
  • 0 likes
  • 2 in conversation