Data visualization with SAS programming

using macro variables in imagename

Accepted Solution Solved
Reply
Contributor
Posts: 57
Accepted Solution

using macro variables in imagename


Hi,

I wanted to use a macro variable &var in the imagename like this:

ods graphics on /

reset=all imagename="ROC_&var";

I got this warning from log

WARNING: The IMAGENAME option or the output name contains invalid characters. ROC_interestrate will be used as the image name

          prefix.

ROC_interestrate is the name that I wanted for my graph. So this warning didnt really affect my result. But I am curious where I did sth. wrong. Can someone please help me?

Thank you very much in advance!

BR  Ding


Accepted Solutions
Solution
‎10-17-2014 09:59 AM
Super User
Super User
Posts: 7,682

Re: using macro variables in imagename

I would suspect from the minimum information the macro variable is resolving with spaces after it, if you are sure there is no special characters.  Try %trim(&var.).  Maybe turn options mprint mlogic symbolgen; so you can see what it is resolving to.

View solution in original post


All Replies
Super Contributor
Posts: 490

Re: using macro variables in imagename

how do you assign the value to the &var.

share your code please

Contributor
Posts: 57

Re: using macro variables in imagename

hi

I use var as an input argument in a %marco(). The values of the var is sth. like interestrate, affordability. I just tried %trim(&var.) and still get the same warning.

BR  Ding

Super Contributor
Posts: 490

Re: using macro variables in imagename

okay input argument to the macro,but share your code to help you further.

Contributor
Posts: 57

Re: using macro variables in imagename

hi

this is a part of the code:

%macro UV(data_in, var, var_class, data_out);

ods html close;

data tmp0;         
format variable $20.;
Variable="&var.";
run;

ods graphics on /
reset = all imagename = "ROC_&var";
ods select ROCCurve;

.....

%mend;

thanks very much!

BR  Ding

Super Contributor
Posts: 490

Re: using macro variables in imagename

I am asking about the part when you assign the value to var and calling UV.

Give example of how you call the UV macro passing the argument to it.

Solution
‎10-17-2014 09:59 AM
Super User
Super User
Posts: 7,682

Re: using macro variables in imagename

I would suspect from the minimum information the macro variable is resolving with spaces after it, if you are sure there is no special characters.  Try %trim(&var.).  Maybe turn options mprint mlogic symbolgen; so you can see what it is resolving to.

SAS Employee
Posts: 170

Re: using macro variables in imagename

Yes, how do you assign 'var'?

For example, this doesn't cause a problem:

%UV(flurg, interstrate, class, foo);

So, what do you do?

And you might try adding the following code to macro UV:

data a;

imagename = "ROC_&var";

put imagename;

run;




🔒 This topic is solved and locked.

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

Discussion stats
  • 7 replies
  • 754 views
  • 6 likes
  • 4 in conversation