What is the sgplot equivalent of:
symbol1 i=sm70;
proc gplot data=somefile;
plot resid*x / vref = 0;
I got a similar graph from doing:
proc sgplot data=somefile;
loess x=x y=resid;
refline 0;
But it seems like the sm70 smoothing function contributes to creating a slightly different graph from the sgplot. What am I missing from the sgplot?
Does it make sense to expect a SPLINE to fit a LOESS curve?
Why not use the SPLINE statement if you want a spline interpolation, which is what sm70 creates?
Does it make sense to expect a SPLINE to fit a LOESS curve?
Why not use the SPLINE statement if you want a spline interpolation, which is what sm70 creates?
To clarify my question, I need to use sgplot instead of gplot beacuse I'm using SAS University Edition. How do I produce the same result using sgplot from the original gplot with symbol1 i=sm70?
Can you post some data so we can replicate it to test?
Trying to read those images isn't going to cut it for testing.
data orig; input age plasma @@;
cards;
0 13.44 0 12.84 0 11.91 0 20.09 0 15.60
1 10.11 1 11.38 1 10.28 1 8.96 1 8.59
2 9.83 2 9.00 2 8.65 2 7.85 2 8.88
3 7.94 3 6.01 3 5.14 3 6.90 3 6.77
4 4.86 4 5.10 4 5.67 4 5.75 4 6.23
;
proc reg data=orig;
model plasma=age;
output out = notrans r = resid;
run;
/*
symbol1 i=sm70;
proc gplot data = notrans;
plot resid*age / vref = 0;
*/
proc sgplot data=notrans;
loess x=age y=resid;
refline 0;
Please try the
goptions interpol=sm70;
Where in the code does the statement have to be inserted?
proc sgplot data=sashelp.enso;
pbspline y=pressure x=month;
run;
proc gplot data=sashelp.enso;
symbol1 color=blue i=sm70;
symbol2 color=red i=none v=circle;
plot pressure*month
pressure*month / overlay;
run; quit;
proc transreg data=sashelp.enso design;
model ide(pressure) = smooth(month / sm=70);
output out=b p;
run;
proc sgplot data=b;
scatter y=pressure x=month;
series y=ppressure x=month;
run;
proc gplot data=b;
symbol1 color=blue i=sm70 v=none;
symbol2 color=red i=none v=circle;
symbol3 color=green i=none v=square;
plot pressure*month pressure*month ppressure*month / overlay;
run; quit;
Personally, I would prefer the penalized b-spline, but I am biased since I wrote it. Decades ago, before ODS, users requested GPLOT smooth functions in an output data set. It was at or near the top of the sasware ballot. I knew GPLOT would never provide it, so I put it in transreg, which fits a lot of other smooth functions. You can then output the smooth function from transreg and put that smooth function into SGPLOT or GPLOT (just to reassure yourself that they are doing the same thing).
Your method of creating a data 'b' also works. But for the sake of succinctness sgplot pbspline produced the same result as gplot. Thank you for providing me with a detailed alternative.
Are you saying you can get precisely the same results from pbspline in sgplot with a smoothing parameter as you get from gplot and sm70? The two methods are quite different. Or are you saying you can get similar smooths? Thanks in advance for clarifying.
Not precise but very close. SPLINE statement doesn't provide the smooth option, so I had no other choice other than to use the PBSPLINE.
You can exactly reproduce the result from PROC GPLOT by using either PROC TRANSREG or PROC IML, as shown in the article "Three ways to add a smoothing spline to a scatter plot in SAS."
However, I recommend one of the statistical fits because then SAS can automatically choose the smoothing parameter based on statistical criteria. See "How to automatically select a smooth curve for a scatter plot in SAS."
I'm not sure what you are saying. Transreg makes graphs, but it is not a graphing procedure per se. I just used it to add a variable to the data set that I then showed how to plot with sgplot and how to verify that it matched gplot. You can add reference lines in the usual way to sgplot.
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
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.