DATA Step, Macro, Functions and more

using a macros parameter in an ODS statement

Reply
N/A
Posts: 0

using a macros parameter in an ODS statement

Hi

I am trying to create a macro that will allow me to produce a box plot and save it as a (.rtf) file using ODS. I want to define the directory to which the file will be saved as a macro parameter. But I am having problems with this step.

I have created the SAS program first (below) and it works

ods listing close;
ods rtf file='c:\data\Boxplot.rtf';
proc sort data = register;
by type;
proc boxplot data=register;
plot sbp*type;
run;
ods rtf close;
ods listing;


However when I create the macro I am having problems defining the directory path as a macro parameter. I have tried different formats to define the ODS directory path in the marco using the parameter (one example below) . However I keep receiving log error that the directory does not exist.


%macro graphics(parm1);
ods listing close;
ods rtf file= &parm1 'Boxplot.rtf';
proc sort data = register;
by type;
proc boxplot data=register;
plot sbp*type;
run;
ods rtf close;
ods listing;
%mend graphics;

%graphics(c:\data\);


I assume I am not using the macro parameter correctly. Any suggestions would be appreciated.

cheers, Alistair Message was edited by: Alby
Valued Guide
Posts: 634

Re: using a macros parameter in an ODS statement

Posted in reply to deleted_user
You are very close. Just a couple of things:
1) Double quotes must be used to surround macro variables that appear inside of quoted strings.
2) The &PARM1 is part of the path and as such must be quoted.
The ODS statement becomes:
[pre]
ods rtf file= "&parm1\Boxplot.rtf";
[/pre]
Art
N/A
Posts: 0

Re: using a macros parameter in an ODS statement

Thanks Art. That worked.

Cheers, Alistair
Ask a Question
Discussion stats
  • 2 replies
  • 130 views
  • 0 likes
  • 2 in conversation