Hi,
I am generating a plot using proc loess as shown below. The output has extra titles I am trying to suppress (and have been successful partially using "ods noptitle"). Can someone advise how I can suppress these titles from my output (since this information is in the plot and is redundant)?
Selected Smoothing Parameter: x | |
Dependent Variable: xyz |
|
ods noptitle;
ods select fitplot;
proc loess data=test;
model dependent = independent /interp=linear degree=1 select=AICC(presearch);
run;
It seems to me that the easiest way to get your plot is to use the OUTPUT statement to save the predicted values. Then sort the data by the independent variable and use PROC SGPLOT to overlay the predicted values on the observed values:
/* create sample data */
data test;
set sashelp.class;
dependent=weight; independent=height;
keep dependent independent;
run;
/* fit loess curve. Save predicted values to SAS data set */
proc loess data=test plots(only)=fitplot;
model dependent = independent /interp=linear degree=1 select=AICC(presearch);
output out=LoessOut predicted=Pred;
run;
/* sort by X */
proc sort data=LoessOut;
by independent;
run;
title "My own title"; /* if you want a title, use this */
title; /* or do not use any title */
proc sgplot data=LoessOut;
scatter x=independent y=dependent;
series x=independent y=Pred;
run;
Do the titles look they might have come from previous TITLE statements?
Try adding:
title;
before the procedure to clear any previous title definitions.
The ODS NOPTITLE only removes Procedure titles such as PROC LOESS or PROC FREQ, not TITLE statements.
Or, edit the template directly.
Thanks for your response Warren! I used GTL to get rid of the "Fit plot for ..." title. I then proceeded to remove all my titles and added in title; title1; statements. They still seem to have no effect on the 2 titles "Smoothing Parameter..." and "Dependant Variable...". I am attaching the output file so it helps you visualize this issue. It seems like these titles are generated by the PROC and the external title statements do not have any bearing on them. Please let me know if you can think of any possible way I can address this.
Thanks for the response Warren! I actually did take a look at your %grtitle blog post and tried using that, but that does not seem to work with Proc LOESS. So I used GTL instead and it helped to some extent - I was able to remove the "Fit Plot for ..." title. However I still have these 2 titles (file attached). The the title; statement does not seem to have any effect on these. I appreciate any help on this matter.
You will have better control on graphical appearance, at the expense of less control about loess computation, with the loess statement available in proc sgplot.
It seems to me that the easiest way to get your plot is to use the OUTPUT statement to save the predicted values. Then sort the data by the independent variable and use PROC SGPLOT to overlay the predicted values on the observed values:
/* create sample data */
data test;
set sashelp.class;
dependent=weight; independent=height;
keep dependent independent;
run;
/* fit loess curve. Save predicted values to SAS data set */
proc loess data=test plots(only)=fitplot;
model dependent = independent /interp=linear degree=1 select=AICC(presearch);
output out=LoessOut predicted=Pred;
run;
/* sort by X */
proc sort data=LoessOut;
by independent;
run;
title "My own title"; /* if you want a title, use this */
title; /* or do not use any title */
proc sgplot data=LoessOut;
scatter x=independent y=dependent;
series x=independent y=Pred;
run;
This worked out for me perfectly! Thank you so much for taking the time to look into this issue and providing a solution.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.