BookmarkSubscribeRSS Feed
Tzippy_Shochat
Calcite | Level 5

Hi All.

I need to create a plot, from SGPLOT, that can be edited in word.

I created an emf plot using SGPLOT.

I am unable to edit this plot in Word

Thanks

14 REPLIES 14
ballardw
Super User

Please show the code you used and best is to provide a small example data set to recreate your graph.

 

Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the </> icon or attached as text to show exactly what you have and that we can test code against.

 

You may also have to set file properties to something other than read only. In some environments I have seen files created with the read only property because of admin or location properties.

Tz
Obsidian | Level 7 Tz
Obsidian | Level 7

Thanks for answering.

Sample code attached.

When I copy the emf graph to word and try to edit it, I see a blank page.

Reeza
Super User

EMF should work fine in theory. Can you show your code that didn't work? Using SASHELP.CLASS is fine for a quick demo.

EyalGonen
Lapis Lazuli | Level 10

Hi @Tz 

 

I searched the support database and it seems like this is a known issue with EMF. I found suggestions to add this code to "fix" the EMF driver. Make sure you run this code in the same SAS session that creates the graph and make sure you run it prior to the graph generation 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;

proc registry import="&workdir./emf94.sasxreg";
run;

Eyal

Tz
Obsidian | Level 7 Tz
Obsidian | Level 7

Thanks Eyal. I'll try this code

Tzippy_Shochat
Calcite | Level 5

Hi Eyal.

 

The above does not work for ODS Graphics output (such as created by SGPLOT)

 

It only works for non ODS plots (such as created by GPLOT)

 

I still can't find a solution

 

Thanks

EyalGonen
Lapis Lazuli | Level 10

Hi @Tzippy_Shochat 

 

I have one more idea and if it does not work I have no more ideas other than open a support ticket so we can investigate this. If you can provide your code and data (or some dummy data) that would make our lives easier 🙂

 

Try adding this code before PROC SGPLOT:

 

ODS LISTING GPATH = 'c:\temp';

ODS GRAPHICSRESET = ALL IMAGEFMT = EMF IMAGENAME = "test" ;

 

This should create a file named "c:\temp\test.emf" that you should be able to edit (or ungroup the image and then edit) in MS Office.

I assume you are running SAS 9.4

 

I want to also point you to another alternative  for editing SAS generated graphs which is the SAS ODS Graphics Editor: https://go.documentation.sas.com/api/docsets/grstateditug/9.4/content/grstateditug.pdf

 

Maybe others have more suggestions for you but it seems like a technical support track is the right way to go

 

Tz
Obsidian | Level 7 Tz
Obsidian | Level 7

Dear Eyal.

Code attached.

Word refuses to edit this plot. If I try to ungroup I get a blank page.

SAS graphics is not an option, as the researcher wants to change graphs inside word.

arielbud
SAS Employee

Hi @Tz 


Can ODS WORD assist instead of ods rtf?

 

%let a=Z:\Pvt\Doron Shulziner\Yellow Vest;


data test;
input Day Value Group;
cards;
1 0.00000 2
2 0.35000 2
3 0.43750 2
4 -0.16667 2
5 0.00000 2
6 -0.12500 2
7 -0.15385 2
8 0.50000 2
9 -0.54545 2
10 0.50000 2
11 -0.04545 2
1 0.50000 3
2 0.22581 3
3 0.21951 3
4 -0.20833 3
5 -0.40541 3
6 -0.07143 3
7 -0.20000 3
8 0.38462 3
9 -0.50000 3
10 0.07692 3
11 -0.14815 3
1 -0.23077 1
2 0.05000 1
3 0.54167 1
4 0.22414 1
5 0.25000 1
6 0.57143 1
7 0.00000 1
8 -0.44444 1
9 0.00000 1
10 0.61538 1
11 0.38710 1
1 -0.25000 4
2 0.00000 4
3 0.00000 4
4 0.25000 4
5 0.40000 4
6 0.33333 4
8 1.00000 4
9 -1.00000 4
10 -1.00000 4
11 0.00000 4
run;

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

proc registry import="&workdir./emf94.sasxreg";
run;

ods html close;
ods listing gpath="&a.\Plots" style=journal;
ods graphics / reset=all imagefmt=emf imagename="test";

ods word file="&a.\Doron Shulziner-Yellow Vest test.docx" ;

proc sgplot data=test;
yaxis min=-1 max=1;
styleattrs
datacontrastcolors=(black)
datalinepatterns=(solid Dash Dot ThinDot);
refline 5 / axis=x;
series x=day y=value / group=group GROUPORDER=Ascending;
run;

ods word close;

 

 

Tz
Obsidian | Level 7 Tz
Obsidian | Level 7
I tried ODS Word with docx. Same result. ord recognizes the plot as EMF but
can't edit it. Thanks
arielbud
SAS Employee

Hi @Tz ,

 

From what I see the issue happens when using 'series' if I use 'scatter' I can edit the picture .
As Eyal suggested please open a new TS (Technical Support) track by sending email to support@sas.com 
Please attach your example and output of 
%put _all_;

proc options value;run;

EyalGonen
Lapis Lazuli | Level 10

Hi @Tzippy_Shochat 

 

I hope you saw @arielbud answer that the problem is due to the use of "series" type of graph. It does sound like a bug.

I found this https://communities.sas.com/t5/Graphics-Programming/Editable-emf-files-for-grouped-series-plots/td-p... in which another user found the same behavior and he even narrowed down the problem even further to the use of a dashed line:

 

Thanks for the comments everyone.  I finally figured out what was causing my problem.  Evidently the EMF output type did not like the dashed line in my plot.  Once I converted the dashed line to a solid line everything worked perfectly.  I'm not sure if EMF just doesn't support dashed lines or if there's something endemic to our system/graph styles but hopefully this information can help someone in the future. 

 

Perhaps you should try to avoid the use of dashed lines and maybe it will help? Let us know, we are curious 🙂

In any case I still think you should open a Technical Support track so we can check with R&D and provide a fix (if neccessary) 

 

Tz
Obsidian | Level 7 Tz
Obsidian | Level 7

Hi All.

Thanks for you're help.

I sent the problem and sample code to support.

I'll keep you updated

 

Tz
Obsidian | Level 7 Tz
Obsidian | Level 7

Hi All. I tried SVG and managed to ungroup.

Thanks

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Discussion stats
  • 14 replies
  • 1450 views
  • 3 likes
  • 6 in conversation