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;
What does your log say?
Bart
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
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.
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).
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.