BookmarkSubscribeRSS Feed
Buzzin124
Calcite | Level 5

I'm trying to make a simple scatterplot using GPLOT but I can't seem to get it working.  I copied the code exactly from lecture, no error messages, nothing in result viewer except my table.   What am I missing?  Thanks for help.  

DATA Plastic;
INPUT hardness time @@;
CARDS;
199 16 205 16 196 16 200 16 218 24 220 24 215 24 223 24 237 32 234 32 235 32 230 32 250 40 248 40 253 40 246 40
; 
RUN;


PROC PRINT DATA=Plastic;
RUN;

SYMBOL1 V=CIRCLE I=SM70S;
PROC GPLOT DATA=Plastic; 
PLOT hardness*time / FRAME;
RUN;
4 REPLIES 4
yabwon
Onyx | Level 15

What does your log say?

 

Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



ballardw
Super User

You have not requested a scatter plot. A scatter plot is generally individual points only. The  Symbol statement option you provided

SYMBOL1 V=CIRCLE I=SM70S;

has an interpolation option, the I= part, that with SM is smoothed line using splines. The 70 is a degree of how much "smoothness" to use with 70 being fairly high on reducing noise (bumps in a line). The last S sorts the X axis values before attempting to plot. So it attempts to place line through the data.

Note: Proc GPLOT wants a QUIT to end the procedure.

The example data you show has multiple y values for each x and very few x values so the vertical nature means the "spline" has some issues. This is shown in this note from the LOG:

NOTE: Input data contained multiple vertical values for individual
      horizontal values. Parametric fit is required to force curve through
      individual observations.

I get this

gplot1.png

Another way to show a simple scatter plot with SGPLOT (which has a bit more flexibility for most things than Gplot)

proc sgplot data=plastic;
   scatter x=time y=hardness;
run;

A regression plot through the points:

proc sgplot data=plastic;
   reg x=time y=hardness;
run;

A penalized spline plot similar yours

proc sgplot data=plastic;
   pbspline x=time y=hardness/smooth=70;
run

There are options with the MARKERATTRS to set size, color and shape of markers. LINEATTRS for color and line pattern.

 

Also, please do not post essentially identical questions on this forum.

Reeza
Super User
What lecture is teaching gplot still?? Definitely use SGPLOT wherever possible.
GraphGuy
Meteorite | Level 14

Do you have a SAS/Graph license?  (if not, your log would probably give you some message)

 

Did you make sure to include the final 'run;' statement (depending on what interface you're using, you might or might not need it).

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 4 replies
  • 1128 views
  • 7 likes
  • 5 in conversation