BookmarkSubscribeRSS Feed
nxa383
Calcite | Level 5

I am having an issue when trying to create a scatter plot in SAS studio. The issue only occurs when I add labels to the observations in the scatter plot. As you will see in the screenshots below, the graph works perfectly fine when there are no labels, but when I add labels to the graph the x-axis gets condensed to the left side of the graph. Any help with this issue would be appreciated.

 No Labels

Screen Shot 2020-07-29 at 1.08.37 AM.png

Code:

ods graphics / reset width=6.4in height=4.8in imagemap;

proc sgplot data=WORK.GOOGLETRENDS;
title height=14pt "Relationship Between Scientific Literacy and Conspiracy Search Frequency by Country";
scatter x=PISAsciencenum y=Conspiracyallnum;
xaxis min=300 max=600 grid label="PISA Scientific Literacy Score";
yaxis grid label="Conspiracy Search Frequency";
run;

ods graphics / reset;

 

Labels 

Screen Shot 2020-07-29 at 1.08.53 AM.png

Code:

ods graphics / reset width=6.4in height=4.8in imagemap;

proc sgplot data=WORK.GOOGLETRENDS;
title height=14pt "Relationship Between Scientific Literacy and Conspiracy Search Frequency by Country";
scatter x=PISAsciencenum y=Conspiracyallnum /datalabel=country;
xaxis min=300 max=600 grid label="PISA Scientific Literacy Score";
yaxis grid label="Conspiracy Search Frequency";
run;

ods graphics / reset;

 

Here is a snapshot of the data structure:

Screen Shot 2020-07-29 at 1.14.23 AM.png

Any help would be appreciated.

2 REPLIES 2
ballardw
Super User

Instead of min=300 max=600 on the Xaxis statement try

values=(300 to 600 by 100) and see if that helps. Or 300 to 700.

Your text label of China, which apparently has an x value very close to upper limit want space to show the text and may be pushing some setting I can't test without data.

nxa383
Calcite | Level 5

Thanks for the response ballardw. I tried increasing the upper limit to 700 and used the value statement you suggested, but unfortunately, the error was not resolved. Here is what the graph looks like with the changes you suggested.   

Screen Shot 2020-07-29 at 11.13.28 AM.png

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!

Tips for filtering data sources in SAS Visual Analytics

See how to use one filter for multiple data sources by mapping your data from SAS’ Alexandria McCall.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 463 views
  • 0 likes
  • 2 in conversation