The data ('length' and 'mass') used for the analysis are created directly within the script via a DATA STEP instruction with 'datalines', meaning they are integrated into the source code and not from an external source.
1 Code Block
DATA STEP Data
Explanation : This DATA STEP block creates a new temporary dataset named 'lizard'. It defines two numeric variables, 'length' and 'mass', and populates them with raw data provided directly in the script via the DATALINES statement. This dataset is the data source for subsequent statistical analyses and visualizations.
Explanation : This PROC NLIN procedure fits a non-linear regression model to the 'lizard' dataset. The specified model is a 'left-plateau model', where the dependent variable 'mass' is constant ('b0') until 'length' reaches 'tau', then it follows a linear relationship. Parameters 'b0', 'b1', and 'tau' are initialized for the procedure. The 'output out=a p=p' option creates a new dataset 'a' that includes the original variables from 'lizard' as well as the 'p' variable, representing the mass values predicted by the model.
Copied!
proc nlin;
parameters b0 = 0.2904 b1 = 0.0189 tau = 23.44;
if length <= tau then do;
model mass = b0;
end;
else do;
model mass = b0 + b1*(length-tau);
end;
output out=a p=p;
run;
1
PROC NLIN;
2
parameters b0 = 0.2904 b1 = 0.0189 tau = 23.44;
3
IFLENGTH <= tau THENDO;
4
model mass = b0;
5
END;
6
ELSEDO;
7
model mass = b0 + b1*(LENGTH-tau);
8
END;
9
OUTPUT out=a p=p;
10
RUN;
3 Code Block
PROC GPLOT
Explanation : This block initializes global graphics options (`GOPTIONS`) to define the appearance of the graphs (colors, fonts, text sizes). It also configures a main title (`title1`), symbol definitions (`symbol1`, `symbol2`), and axis specifications (`axis1`, `axis2`) including labels and ranges. The `PROC GPLOT` procedure is then used to generate a simple scatter plot ('mass' vs 'length') from dataset 'a', using the previously established axis definitions.
Copied!
goptions reset=global gunit=pct border cback=white
colors=(black blue green red)
ftitle=swissb ftext=swiss htitle=4 htext=4;
title1 'Mass vs Length with the fit';
symbol1 color=red
interpol=none
value=dot
height=3;
symbol2 color=red
interpol=join;
axis1 label=('Length (mm)')
order=(22 to 28 by 1)
width=3;
axis2 label=('Mass (g)')
order=(0.25 to .45 by 0.05)
width=3;
proc gplot data=a;
plot mass*length/ haxis=axis1 vaxis=axis2;
run;
Explanation : This final block uses `PROC GPLOT` to create an overlaid graph. It plots the observed data ('mass' vs 'length') and the model's predicted values ('p' vs 'length') on the same graph from dataset 'a'. The `overlay` option allows visualizing both series on the same coordinate system, facilitating comparison between actual observations and the model's fit. The previously defined axis configurations are reused.
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.
Related Documentation
Aucune documentation spécifique pour cette catégorie.
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.