The script begins by creating a `SocEcon` table containing five socio-economic variables via a DATA step. It then proceeds to calculate a correlation matrix with `PROC CORR`. A second CORR type table is also created manually. The core of the analysis relies on `PROC REG`, which is used twice: first to fit two regression models and save their estimates and covariances (`OUTEST=regest COVOUT`), then to generate the matrix of sums of squares and cross products (`OUTSSCP=regsscp`). The intermediate result tables (`corrcorr`, `datacorr`, `regest`, `regsscp`) are displayed with `PROC PRINT` for inspection.
Data Analysis
Type : CREATION_INTERNE
The two data tables used, `SocEcon` and `datacorr`, are created within the script using the `datalines` instruction. No external data source is necessary.
1 Code Block
DATA STEP Data
Explanation : This DATA STEP block creates the `SocEcon` working table. It reads 12 observations for 5 socio-economic variables (Pop, School, Employ, Services, House) directly from the code using the `datalines` instruction.
title2 'Harman (1976), Modern Factor Analysis, Third Edition';
3
4
DATA SocEcon;
5
INPUT Pop School Employ Services House;
6
DATALINES;
7
570012.8250027025000
8
100010.96001010000
9
34008.81000109000
10
380013.6170014025000
11
400012.8160014025000
12
82008.326006012000
13
120011.44001016000
14
910011.533006014000
15
990012.5340018018000
16
960013.7360039025000
17
96009.633008012000
18
940011.4400010013000
19
;
20
2 Code Block
PROC CORR Data
Explanation : `PROC CORR` procedure calculates the correlation matrix for all numeric variables in the `SocEcon` table. The `noprint` option suppresses display in the standard output, and `out=corrcorr` saves the results in a new table named `corrcorr`. This table is then displayed with `PROC PRINT` and its structure is inspected with `PROC CONTENTS`.
Explanation : This DATA STEP manually creates a special SAS CORR type table named `datacorr`. This table type can be used as input by other statistical procedures. The correlation matrix data is read from the `datalines`. The resulting table is displayed with `PROC PRINT`.
Copied!
title 'Five Socioeconomic Variables';
data datacorr(type=corr);
infile cards missover;
_type_='corr';
input _Name_ $ Pop School Employ Services House;
datalines;
Pop 1.00000
School 0.00975 1.00000
Employ 0.97245 0.15428 1.00000
Services 0.43887 0.69141 0.51472 1.00000
House 0.02241 0.86307 0.12193 0.77765 1.00000
;
proc print data=datacorr;
run;
1
title 'Five Socioeconomic Variables';
2
3
DATA datacorr(type=corr);
4
INFILECARDS missover;
5
_type_='corr';
6
INPUT _Name_ $ Pop School Employ Services House;
7
DATALINES;
8
Pop 1.00000
9
School 0.009751.00000
10
Employ 0.972450.154281.00000
11
Services 0.438870.691410.514721.00000
12
House 0.022410.863070.121930.777651.00000
13
;
14
15
PROC PRINTDATA=datacorr;
16
RUN;
4 Code Block
PROC REG Data
Explanation : This `PROC REG` procedure performs two linear regression analyses on the `SocEcon` table. The results (parameter estimates) are stored in the `regest` table using `outest=regest`. The `covout` option includes the covariance matrix of the estimates. Both models, 'full' and 'empser', are specified. The `regest` result table is then printed.
Copied!
proc reg data=SocEcon outest=regest covout;
full: model house=pop school employ services / noprint;
empser: model house=employ services / noprint;
quit;
proc print data=regest;
run;
1
PROC REGDATA=SocEcon outest=regest covout;
2
full: model house=pop school employ services / noprint;
3
empser: model house=employ services / noprint;
4
QUIT;
5
6
PROC PRINTDATA=regest;
7
RUN;
5 Code Block
PROC REG Data
Explanation : A second execution of `PROC REG` is used to generate the matrix of sums of squares and cross products (SSCP) for the model variables. The result is stored in the `regsscp` table via the `outsscp=regsscp` option. The `regsscp` table is then displayed for verification.
Copied!
proc reg data=SocEcon outsscp=regsscp;
model house=pop school employ services / noprint;
quit;
proc print data=regsscp;
run;
1
PROC REGDATA=SocEcon outsscp=regsscp;
2
model house=pop school employ services / noprint;
3
QUIT;
4
5
PROC PRINTDATA=regsscp;
6
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.