BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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
2 REPLIES 2
ArtC
Rhodochrosite | Level 12
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
deleted_user
Not applicable
Thanks Art. That worked.

Cheers, Alistair

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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