The script begins by creating a 'Sim' table via an iterative loop generating 100 observations with correlated variables (x, y, z) and a sum (s). It then displays the data, executes three linear regression models (simple and multiple) to explore the relationships between the variables, and concludes with a regression plot showing confidence and prediction intervals.
Data Analysis
Type : CREATION_INTERNE
The data is entirely generated in the first DATA step 'Sim' using loops and random functions (ranuni).
1 Code Block
DATA STEP Data
Explanation : Creation of the 'Sim' work table containing 100 artificially generated observations. Variables x, y, and z are created with mathematical relationships and a random component.
Copied!
data Sim;
do i=1 to 100;
x=i; y=i*2+ranuni(1234); z=-x+ranuni(4321);
s=x+z;
output;
end;
run;
1
DATA Sim;
2
DO i=1 to 100;
3
x=i; y=i*2+ranuni(1234); z=-x+ranuni(4321);
4
s=x+z;
5
OUTPUT;
6
END;
7
RUN;
2 Code Block
PROC PRINT
Explanation : Displaying the content of the 'Sim' table in the standard output.
Copied!
proc print;run;
1
PROC PRINT;RUN;
3 Code Block
PROC REG
Explanation : Simple linear regression modeling explaining variable y by x.
Copied!
proc reg data=sim;
model y=x;
run;
1
PROC REGDATA=sim;
2
model y=x;
3
RUN;
4 Code Block
PROC REG
Explanation : Simple linear regression modeling explaining variable y by z.
Copied!
proc reg data=sim;
model y=z;
run;
1
PROC REGDATA=sim;
2
model y=z;
3
RUN;
5 Code Block
PROC REG
Explanation : Multiple linear regression modeling explaining variable y by variables x and z simultaneously.
Copied!
proc reg data=sim;
model y=x z;
run;
1
PROC REGDATA=sim;
2
model y=x z;
3
RUN;
6 Code Block
PROC SGPLOT
Explanation : Creation of a regression plot showing the relationship between s (x-axis) and y (y-axis), including confidence limits for the mean (CLM) and for individuals (CLI).
Copied!
proc sgplot data=sim;
reg x=s y=y / CLM CLI;
run;
1
PROC SGPLOTDATA=sim;
2
reg x=s y=y / CLM CLI;
3
RUN;
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.
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.