BookmarkSubscribeRSS Feed
brophymj
Quartz | Level 8

The below code works fine when I don't use a macro but when try to build a macro to allow for different paths, flags, it fails to execute. Is my macro notation incorrect?

%macro exportgraphs(folder,flag);

  options orientation=landscape nodate nonumber;

  ods listing gpath="H:\&folder.\";
  ods pdf file="H:\&folder.\&flag..pdf" columns=2 style=meadow startpage=no;
  ods graphics on/width=4.5in height=3.75in;

  proc sgplot data=dataset( where=(&flag = "Y" ));
     title "title ";
     vbar level / response=exposure;
     vline level / response=all_LR y2axis;
  run;

  

%mend;

%exportgraphs(Under 10 levels,flag1);

2 REPLIES 2
djrisks
Barite | Level 11

I would add ods pdf close; before the %mend statement, and use %exportgraphs(%str(Under 10 levels),flag1) instead of %exportgraphs(Under 10 levels,flag1);

ballardw
Super User

Does the folder path exist before the code is run? i.e h:\Under 10 levels ? That could be an issue as well, or if the existing folder is named H:\ Under 10 levels   (note space before Under) and if you are running on Unix then case of the folder name becomes an issue.

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
  • 819 views
  • 3 likes
  • 3 in conversation