This script creates a 'Melanoma' dataset containing annual records. It begins by visualizing raw data with PROC SGPLOT. Then, it progressively uses PROC LOESS: first with default parameters, then by requesting statistical details, comparing different smoothing parameters (smooth option), exporting results via ODS OUTPUT, and finally displaying confidence intervals (CLM).
Data Analysis
Type : INTERNAL_CREATION
Data is included directly in the script via the DATALINES statement (Melanoma dataset).
1 Code Block
DATA STEP Data
Explanation : Creation of the 'Melanoma' dataset. The INPUT statement is configured to read multiple 'Year Incidence' pairs per line (note: the source code contains a file reference artifact where the '@@' symbol is expected for continuous reading).
Explanation : Activation of ODS graphics. First execution of PROC LOESS with default options to fit a local regression curve.
Copied!
ods graphics on;
proc loess data=Melanoma;
model Incidences=Year;
run;
1
ods graphics on;
2
3
PROC LOESSDATA=Melanoma;
4
model Incidences=Year;
5
RUN;
4 Code Block
PROC LOESS
Explanation : Execution of PROC LOESS requesting additional details in the output: model summary and output statistics.
Copied!
proc loess data=Melanoma;
model Incidences=Year / details(ModelSummary OutputStatistics);
run;
1
2
PROC LOESS
3
DATA=Melanoma;
4
model Incidences=Year / details(ModelSummary OutputStatistics);
5
RUN;
6
5 Code Block
PROC LOESS Data
Explanation : Modeling with explicit specification of several smoothing parameters for comparison. The 'residual' option requests residual calculation. Output statistics are saved to the SAS table 'Results' via ODS OUTPUT.
model Incidences=Year/smooth=0.10.250.40.6 residual;
3
ods OUTPUT OutputStatistics=Results;
4
RUN;
6 Code Block
PROC PRINT
Explanation : Display of the first 5 observations from the previously created 'Results' table.
Copied!
proc print data=Results(obs=5);
id obs;
run;
1
PROC PRINTDATA=Results(obs=5);
2
id obs;
3
RUN;
7 Code Block
PROC LOESS
Explanation : Execution aimed at producing a specific plot of residuals by smoothing parameter (ResidualsBySmooth).
Copied!
proc loess data=Melanoma plots=ResidualsBySmooth(smooth);
model Incidences=Year/smooth=0.1 0.25 0.4 0.6;
run;
1
2
PROC LOESS
3
DATA=Melanoma plots=ResidualsBySmooth(smooth);
4
model Incidences=Year/smooth=0.10.250.40.6;
5
RUN;
6
8 Code Block
PROC LOESS
Explanation : Final model requesting confidence limits (CLM) with an alpha threshold of 0.1 (90% confidence interval). ODS graphics are turned off at the end.
Copied!
proc loess data=Melanoma;
model Incidences=Year/clm alpha=0.1;
run;
ods graphics off;
1
PROC LOESSDATA=Melanoma;
2
model Incidences=Year/clm alpha=0.1;
3
RUN;
4
5
ods graphics off;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
« When dealing with time-series data like melanoma incidences, a simple linear regression often fails to capture localized fluctuations. PROC LOESS (LOcal regrESSion) provides a non-parametric alternative, creating a smooth curve that "follows" the data points without forcing them into a rigid global mathematical shape (like a straight line or parabola). »
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.