BookmarkSubscribeRSS Feed
bortonek
Calcite | Level 5

 

GOAL:  Use PROC GPLOT to create a graph that can be copied and pasted into MS Word with editable properties.

 

BACKGROUND: I used SAS 9.3 that created a PROC GPLOT graph in the "Results" which could be simply copied and pasted into MS Word 2010.  The copied graphic in Word appeared to contain data since I could move my cursor and see data points along my graph plus click the graph that brought up various graph formatting options to edit lines, fonts, graph characteristics etc... it was great.

 

PROBLEM:  I upgraded to SAS 9.4.  I ran the same program but the copied graphic now pastes into Word 2010 like a regular image file and selection of the graphic only allows the "usual" right click file options in Word.  What happened to this wonderful feature?

 

I tried googling and found .EMF goptions and other advice but none seemed to work.

Am I missing the wrong Google search keyword or is .EMF not the problem when SAS was updated to version 9.4?

 

Advice I tried to follow included the following although PROC SGPLOT is not being used.

https://communities.sas.com/t5/Graphics-Programming/SAS-ODS-Graphics-to-MS-Word-Advice-Wanted/td-p/3...

https://communities.sas.com/t5/Graphics-Programming/Creating-editable-ungroupable-graphs-in-powerpoi...

 

Thank you.

 

 

12 REPLIES 12
Reeza
Super User
Did you try the suggestions from SAS tech support?


Re: Creating editable (ungroupable) graphs in powerpoint 2010
Options
Posted in reply to Quentin
‎2017-08-28 12:48 PM

Here's the reply from SAS. I have yet to try it though.



This is a known issue with SAS 9.4. The problem is due to a change to our EMF support that R&D made for 9.4. To see if this circumvents the problem, modify your SAS code by adding the following code to the top of your existing code:

%let workdir=%trim(%sysfunc(pathname(work)));

data _null_;
file "&workdir./emf94.sasxreg";
put '[CORE\PRINTING\PRINTERS\EMF\ADVANCED]';
put '"Description"="Enhanced Metafile Format"';
put '"Metafile Type"="EMF"';
put '"Vector Alpha"=int:0';
put '"Image 32"=int:1';
run;

/* Import the file */
proc registry import="&workdir./emf94.sasxreg";
run;

The code above modifies the SAS registry in your SASUSER directory and changes the default EMF support back to what it was with 9.3. If the code above works for you, you should only have to submit the code above once to SAS. The change should stay in effect for subsequent SAS sessions.
bortonek
Calcite | Level 5

Yes, I have tried that suggestion hoping that would work.  I did not change anything to the code including "pathname" in the snippet, "%let workdir=%trim(%sysfunc(pathname(work)));"

 

 

Reeza
Super User

Yeah, you're not supposed to change anything. That does work for me. 

 

So to clarify, you ran the modification above, and tried an EMF output format and it doesn't work? It does with SGPLOT for me. 

 

ods graphics / imagefmt=emf;
ods rtf file='C:\_localdata\temp\demo.rtf';

proc sgplot data=sashelp.class;
scatter x=height y=weight / group=sex;
run;

ods rtf close;
bortonek
Calcite | Level 5
I am using a PROC GPLOT so the ODS options may not work.


proc gplot data=Stackeddata;
PLOT (CumArea_pct_1-CumArea_pct_&BANDNUM.) * xvar_days/OVERLAY AREAS=&BANDNUM. legend=legend1
NOFRAME HAXIS= axis1 VAXIS=axis2 VREF=50 cv=black HREF=&call3min. &call3max. lh=3 ch=lightgrey ;
run;


Reeza
Super User
No, you'll have to use the Graphics method to set the output to EMF instead but I suspect that's all you need. Have you set the output format to EMF?
bortonek
Calcite | Level 5
I did try going into the options under "Tools" and set the graph format to SAS EMF. Again nothing seemed to work.


Reeza
Super User

This also works for me:

 

ods rtf file='C:\_localdata\temp\demo2.rtf' device=emf;

proc gplot data=sashelp.class;
plot height*weight;
run;

ods rtf close;
bortonek
Calcite | Level 5
So I tried the code:



ods rtf file='C:\_localdata\temp\demo2.rtf' device=emf;



proc gplot data=sashelp.class;

plot height*weight;

run;



ods rtf close;



It creates the demo2.rtf file which I opened in Word. Again, it creates a graphic but a right click does not allow all the various editing. It does show "Edit Picture" as an option once I right click on it. This brings up a dialogue box stating "This is an imported picture, not a group. Do you want to convert it to a Microsoft Office drawing object?" Clicking yes causes the Word document to go blank.


Reeza
Super User

So clicking yes, then causes me to have the graph and be able to format points. I'm using SAS 9.4 TS1M5 and have run that code above with no errors to modify the EMF portion. If you have the same set up you may want to contact SAS tech support.

FYI - a workaround is to use the ODS Graphics Designer which includes all of the features you're looking for, but you do need to use SGPLOT I believe. It does allow for a lot of customization though.

EDIT: And using Office 2016.

bortonek
Calcite | Level 5
It seems I am now getting a warning message:



"WARNING: Unsupported device 'SASEMF' for TAGSETS.SASREPORT13(EGSR) destination. Using default device 'PNG'.



Is there another setting or option needed?


Reeza
Super User
That's because you still have the HTML or Report destinations open, it shouldn't affect your RTF output though. You can also close the other destinations or outputs and leave only the RTF. You can control that in preferences or via code using ODS <destination> close; to close a destination.
Doug____
Pyrite | Level 9

I also attempted this technique and it did not work in the RTF destination. When I click to edit the graph in word it disappears from the page. The code I used is shown below on 9.4 M7.

 


%let workdir=%trim(%sysfunc(pathname(work)));
data _null_;
file "&workdir./emf94.sasxreg";
put '[CORE\PRINTING\PRINTERS\EMF\ADVANCED]';
put '"Description"="Enhanced Metafile Format"';
put '"Metafile Type"="DUAL"';
run;
proc registry import="&workdir./emf94.sasxreg";
run;
ods graphics/ height = 6in width = 10.5in attrpriority = none outputfmt=emf;
ods rtf file = ".\Documents\Reports\ test emf.rtf" device = emf;

 


PROC SGPLOT DATA = ADVA2;
styleattrs datasymbols= (CircleFilled CircleFilled)
datacontrastcolors=(green orange)
datalinepatterns= (dash solid);

SERIES X = WEEK Y = letters /LINEATTRS=(thickness = 2pt) GROUP = RPECAT NAME = 'S' groupdisplay = cluster ;
SCATTER X = WEEK Y = letters /YERRORUPPER = LCL YERRORLOWER=UCL GROUP = RPECAT
GROUPDISPLAY = CLUSTER ERRORBARATTRS = (THICKNESS = 2pt)
/*MARKERFILLATTRS = (size = 3pt)*/ markerattrs = (size = 8pt );
KEYLEGEND 'S' / noborder valueattrs = (size = 8pt) ;
XAXIS LABEL = "Week" values = (-8 1 5 8 12 24 36 48 72 96) grid labelattrs=(size = 8pt) valueattrs=(size = 8pt);
yaxis label = "Mean BCVA (Letters)" grid values = (-20 to 100 by 10) grid valueshint labelattrs=(size = 8pt) valueattrs=(size = 8pt);
label week ="Week" letters= "Mean" ucl="95% UCL" lcl = "95% LCL" recs = 'n';
xaxistable recs / x = week classorder = ascending class = rpecat valueattrs = (size = 8pt) colorgroup = rpecat;
RUN;
ods rtf close;


;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 12 replies
  • 2126 views
  • 0 likes
  • 3 in conversation