BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Esterina
Obsidian | Level 7

Hi all,

 

I'm trying to find the posibility to create a scatter plot graph with many labels that can be adjusted manually. I know that using SAS Graph Template Language we can create a scatter plot with auto adjustment on the labels, and I'm quite pleased with this, but just in case if the labels are still too closed and overlapped I would have the capability to adjust it manually too. Is it possible to do this? I heard activeX graph will be deprecated and ODS Graphics Editor too.

Thank you in advance!

 

Here is the sample graph 

g2_try.png

1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

I'm not sure where the final destination is for your graph, but here is one way to do it. First, generate your output using the ODS WORD destination. Here is an example:

ods _all_ close;
ods word file="class.docx";
ods graphics / outputfmt=svg;
proc sgplot data=sashelp.class;
scatter x=weight y=height / datalabel=name;
run;
ods _all_ close;

Next, open the file in Microsoft Word. Right-click on the graph and select, "Convert to Shape". You can then edit and move your labels. Then, deselect the graph, right-click on it, and select, "Save as Picture". This image will external save your edits as a PNG image.

 

Hope this helps!

View solution in original post

6 REPLIES 6
Ksharp
Super User

Try datalabel= option, that would avoid to overlap the two closed label .

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

Ksharp_0-1707279935021.png

As you can see there is no overlapped label , sas just do it for you .

Esterina
Obsidian | Level 7

Thanks! I know this one, but I'm looking a way to make it interactive, that we can adjust the labels manually by drag and drop.

DanH_sas
SAS Super FREQ

On the ODS GRAPHICS statement, there is an option called LABELPOSITION that contains two fitting algorithms: GREEDY and SA (simulated annealing). The default is GREEDY, which works pretty well. However, if you have cases where GREEDY does not produce what you want, try SA. The graph might take a little longer to produce, but it might give you better results in some dense cases.

Esterina
Obsidian | Level 7

Thanks Dan! that's good to know. But I'm looking a way to make it interactive that I can adjust the labels manually after that by drag and drop.

DanH_sas
SAS Super FREQ

I'm not sure where the final destination is for your graph, but here is one way to do it. First, generate your output using the ODS WORD destination. Here is an example:

ods _all_ close;
ods word file="class.docx";
ods graphics / outputfmt=svg;
proc sgplot data=sashelp.class;
scatter x=weight y=height / datalabel=name;
run;
ods _all_ close;

Next, open the file in Microsoft Word. Right-click on the graph and select, "Convert to Shape". You can then edit and move your labels. Then, deselect the graph, right-click on it, and select, "Save as Picture". This image will external save your edits as a PNG image.

 

Hope this helps!

Esterina
Obsidian | Level 7
oh.. this is so great Dan! Thanks! But my graph is squished, I think because it can't show the original size, so then I need to adjust the outlook? because currently I just ods html and device= gif. Do you have any suggestion to make my graph is like the original size or it is not possible?

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!

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