Published on :
Statistical CREATION_INTERNE

Data Simulation and Regression Analysis

This code is also available in: Deutsch Español Français
Awaiting validation
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!
1DATA 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;
7RUN;
2 Code Block
PROC PRINT
Explanation :
Displaying the content of the 'Sim' table in the standard output.
Copied!
1PROC PRINT;RUN;
3 Code Block
PROC REG
Explanation :
Simple linear regression modeling explaining variable y by x.
Copied!
1PROC REG DATA=sim;
2 model y=x;
3RUN;
4 Code Block
PROC REG
Explanation :
Simple linear regression modeling explaining variable y by z.
Copied!
1PROC REG DATA=sim;
2 model y=z;
3RUN;
5 Code Block
PROC REG
Explanation :
Multiple linear regression modeling explaining variable y by variables x and z simultaneously.
Copied!
1PROC REG DATA=sim;
2 model y=x z;
3RUN;
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!
1PROC SGPLOT DATA=sim;
2 reg x=s y=y / CLM CLI;
3RUN;
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.