BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
DanJensen
Calcite | Level 5

Hello, I am new to the SAS forum.  I am looking for some assistance in formatting a couple of scatterplots for my M.Sc thesis.  I am using SAS 9,3

I have created the scatterplot and trendlines in Proc SGPlot, however there are two minor issues that I need to resolve

1) The data is grouped, and in the legend that is created the group names (which are numbers) get truncated using scientific notation.  Is there a way to get SG plot to show the entire number in the Legend?  The entire number is needed for the legend to make sense.

2) For the Axis titles my units are in Square meters.  Is it possible to incorporate superscripts into the axis titles?

I would appreciate any feedback I can get.

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

Hi Dan,

The first part of my code was simply there to create example data for plotting, you can ignore it. All you need to do is :

proc sgplot data=Chapter2AspenNLinOut;

scatter x=LiDARGapArea y=ExpandedGapArea / group=Polygon;

series x=LiDARGapArea y=Pred / group=Polygon;

yaxis label='Expanded Gap Area (m²)';

xaxis label='LiDAR Gap Area (m²)';

format Polygon best20.;

run;

PG

PG

View solution in original post

6 REPLIES 6
PGStats
Opal | Level 21

1) Use an explicit format for your group variable

2) Use Unicode character '00B2' which represents superscript 2 (you might be able to cut and paste it from the code below)

data test;

call streaminit(76576);

do group = 121212121212211, 63565345534556;

    do x = 1 to 12;

        y = sum(y, rand('Normal'));

        output;

        end;

    end;

run;

title;

proc sgplot data=test;

format group best20.;

series x=x y=y / group=group;

yaxis label="Y (m²)";

run;

SGPlot3.png

PG

PG
DanJensen
Calcite | Level 5

Thanks for the prompt response,

I have attempted the "do" statement and I think my inexperience is showing.  When I included a do statement the log stated that I needed an end statement as well. Here is the code I was using,

proc nlin data=Aspen  NLINMEASURES plots(stats=all)=(diagnostics) ;

ods rtf file="D:\Chapter2DataTables\AspenPowerFunction.rtf";

  parms a=30 b=0.4;

    model Y=a*X**b;

    by polygon;

  do group = 6796103, 6886289; tried to add the do statement here...

  Output Out=Chapter2.AspenNlinOut Predicted=pred;

run;

ods rtf close;

Title test;

proc sgplot data=Chapter2.AspenNLinOUt;

Scatter x=LiDARGapArea y=ExpandedGapArea / group=Polygon;

yaxis label='Expanded Gap Area (m²)';

xaxis label='LiDAR Gap Area (m²)';

series x=LiDARGapArea y=Pred / group=Polygon;

run;

PGStats
Opal | Level 21

Hi Dan,

The first part of my code was simply there to create example data for plotting, you can ignore it. All you need to do is :

proc sgplot data=Chapter2AspenNLinOut;

scatter x=LiDARGapArea y=ExpandedGapArea / group=Polygon;

series x=LiDARGapArea y=Pred / group=Polygon;

yaxis label='Expanded Gap Area (m²)';

xaxis label='LiDAR Gap Area (m²)';

format Polygon best20.;

run;

PG

PG
DanJensen
Calcite | Level 5

The format statement solved it.  Thanks very much for the assistance.

DanJensen
Calcite | Level 5

Thanks again for the assistance before.

I have been asked to modify the scatter plots a little more.  The current plots create an output which is distinguished only by color.  I have been asked to change up one set of data points so that the markers and series line are different (maybe change them to closed circles and a dashed line).  With the data sets being separated using the group statements I am not sure how to modify them to change only one set of markers.  Any ideas would be appreciated.  I haven't seen anything in the other posts in this forum yet.

proc sgplot data=Chapter2.AspenNLinOUt;

Scatter x=LiDARGapArea y=ExpandedGapArea / group=Polygon;

yaxis label='Expanded Gap Area (m²)';

xaxis label='LiDAR Gap Area (m²)';

series x=LiDARGapArea y=Pred / group=Polygon markerattrs=;

format Polygon best20.;

run;

Thanks again for the assistance.

PGStats
Opal | Level 21

You should change the style associated with your ODS destination. By default the style is HTMLBLUE which only changes colors among the first 12 groups. The alternate style HTMLBLUECML (CML: Color-Marker-Line) changes every aspect from one group to the other. Add a statement such as

ODS HTML style=HTMLBLUECML;

before proc sgplot to request the alternate style. Also, remove the markerattrs= request from the series statement.

PG

PG

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 2311 views
  • 3 likes
  • 2 in conversation