BookmarkSubscribeRSS Feed
Whitlea
Fluorite | Level 6

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!

6 REPLIES 6
ballardw
Super User

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.

Whitlea
Fluorite | Level 6

When I made the changes is ignored my filename and created a blank EMF.

Any other suggestions ?

ballardw
Super User

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.

 

 

DanH_sas
SAS Super FREQ

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";

 

 

 

DanH_sas
SAS Super FREQ

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";

 

 

 

Whitlea
Fluorite | Level 6

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;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 6 replies
  • 2303 views
  • 0 likes
  • 3 in conversation