I have SAS 9.4 and I am trying to generate multiple graphs from a proc template using:
ods _all_ close;
ods graphics on / reset=all width=6.0in height=3.5in noborder IMAGEFMT=EMFdual noscale ;
ods html close ;
ods printer printer=emfdual;
options nodate nonumber printerpath=emfdual;
filename output "d:\data\&var.emf";
This will only output the first observation of my macro and it completely ignores my output destination. I have tried other options and most of them appear to generate emf output but they are really PNGs.
Any suggestions ?
Thanks!
If you want the filename to reference a file with an extension of emf change:
filename output "d:\data\&var.emf";
to
filename output "d:\data\&var..emf";
The . following a macro variable tells the macro processor to combine the next text so you need a second one as part of the extension.
You will want to add an ods graphics option to specify the graphic immage format
ods graphics/ imagefmt=EMF;
When you do not specify and imagefmt the default is chosen based on the target destination and most of those will generate PNG.
When I made the changes is ignored my filename and created a blank EMF.
Any other suggestions ?
Missed tha tyou had immage fmt.
Show the log of the code ran with any messages to include the
You aren't referencing the filename for your output on the filepath option.
try changing it to Printerpath(emfdual output);
Output because that is the name of the FILENAME.
It may not hurt to have the printerpath set before the ODS PRINTER statement so that statment knows where things are going.
You may need to verify that you have a printer emfdual. I know I don't have one.
Instead of ODS PRINTER, try this instead:
ods _all_ close;
ods listing gpath="d:\data";
ods graphics on / reset=all width=6.0in height=3.5in noborder IMAGEFMT=EMFdual
noscale imagename="&var..emf";
Instead of ODS PRINTER, try this instead:
ods _all_ close;
ods listing gpath="d:\data";
ods graphics on / reset=all width=6.0in height=3.5in noborder IMAGEFMT=EMFdual
noscale imagename="&var..emf";
This code you suggested created files for all observations with the file names to the right destination but the emf files were blank. Here is the proc template I am trying to generate an emf for ...
%Macro Graph;
proc template;
define statgraph district;
begingraph / datacolors=(white CXEBDDED CXEBDDED CXEBDDED CXEBDDED CXEBDDED CXEBDDED CXEBDDED) ;
layout overlay / walldisplay=(fill) xaxisopts=(display=( line tickvalues)
DISCRETEOPTS=(TICKVALUEFITPOLICY=split TICKVALUESPLITJUSTIFY=center) labelattrs=(family='GraphLabelText' size=10pt))
yaxisopts=( offsetmin=0 linearopts=(viewmin=0 viewmax=&vmax tickvaluelist=(0 &Mid &Max)));
barchartparm x=district y=percent / group=district groupdisplay=cluster errorupper=uppct errorlower=lowpct
ERRORBARATTRS=(color=black)
OUTLINEATTRS=(color=black);
scatterplot y=dataloc x=district / markercharacter=percent MARKERCHARACTERATTRS=(size=10pt FAMILY='GraphValueText');
endlayout;
endgraph;
end;
run;
proc sgrender data=district template=district ;
format district district.;
run;
%Mend Graph;
ods _all_ close;
ods listing gpath="d:\data";
ods graphics on / reset=all width=6.0in height=3.5in noborder IMAGEFMT=EMFdual
noscale imagename="&var..emf";
/*Output(Var,Max,vmax,Mid,Lev)*/
%Output (Z_GENHLT, 50,50, 25, 2, );
%Output (Z_HCCOVR, 50,50, 25, 2, ) ;
ods graphics off;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Lock in the best rate now before the price increases on April 1.
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.
Ready to level-up your skills? Choose your own adventure.