This script creates a dataset containing the population of different US regions over several decades. It uses specific weighting to treat Alaska and Hawaii as supplementary observations (negative weight). Then, the PROC CORRESP procedure is used to perform a simple correspondence analysis, displaying row/column profiles, contributions to Chi-2, and generating a correspondence plot.
Data Analysis
Type : CREATION_INTERNE
Data is integrated directly into the code via the DATALINES statement within the DATA step.
1 Code Block
DATA STEP Data
Explanation : Creation of the 'USPop' dataset containing regional populations. The 'w' variable is calculated to weight observations, assigning a negative weight to Alaska and Hawaii to treat them as supplementary observations in the subsequent analysis.
Copied!
title 'United States Population, 1920-1970';
data USPop;
* Regions:
* New England - ME, NH, VT, MA, RI, CT.
* Great Lakes - OH, IN, IL, MI, WI.
* South Atlantic - DE, MD, DC, VA, WV, NC, SC, GA, FL.
* Mountain - MT, ID, WY, CO, NM, AZ, UT, NV.
* Pacific - WA, OR, CA.
*
* Note: Multiply data values by 1000 to get populations.;
input Region $14. y1920 y1930 y1940 y1950 y1960 y1970;
label y1920 = '1920' y1930 = '1930' y1940 = '1940'
y1950 = '1950' y1960 = '1960' y1970 = '1970';
if region = 'Hawaii' or region = 'Alaska'
then w = -1000; /* Flag Supplementary Observations */
else w = 1000;
datalines;
New England 7401 8166 8437 9314 10509 11842
NY, NJ, PA 22261 26261 27539 30146 34168 37199
Great Lakes 21476 25297 26626 30399 36225 40252
Midwest 12544 13297 13517 14061 15394 16319
South Atlantic 13990 15794 17823 21182 25972 30671
KY, TN, AL, MS 8893 9887 10778 11447 12050 12803
AR, LA, OK, TX 10242 12177 13065 14538 16951 19321
Mountain 3336 3702 4150 5075 6855 8282
Pacific 5567 8195 9733 14486 20339 25454
Alaska 55 59 73 129 226 300
Hawaii 256 368 423 500 633 769
;
1
title 'United States Population, 1920-1970';
2
3
DATA USPop;
4
5
* Regions:
6
* New England - ME, NH, VT, MA, RI, CT.
7
* Great Lakes - OH, IN, IL, MI, WI.
8
* South Atlantic - DE, MD, DC, VA, WV, NC, SC, GA, FL.
9
* Mountain - MT, ID, WY, CO, NM, AZ, UT, NV.
10
* Pacific - WA, OR, CA.
11
*
12
* Note: Multiply data values by 1000 to get populations.;
13
14
INPUT Region $14. y1920 y1930 y1940 y1950 y1960 y1970;
THEN w = -1000; /* Flag Supplementary Observations */
21
ELSE w = 1000;
22
23
DATALINES;
24
New England 74018166843793141050911842
25
NY, NJ, PA 222612626127539301463416837199
26
Great Lakes 214762529726626303993622540252
27
Midwest 125441329713517140611539416319
28
South Atlantic 139901579417823211822597230671
29
KY, TN, AL, MS 8893988710778114471205012803
30
AR, LA, OK, TX 102421217713065145381695119321
31
Mountain 333637024150507568558282
32
Pacific 556781959733144862033925454
33
Alaska 555973129226300
34
Hawaii 256368423500633769
35
;
2 Code Block
SAS SYSTEM
Explanation : Activation of the ODS Graphics system for generating statistical plots.
Copied!
ods graphics on;
1
ods graphics on;
3 Code Block
PROC CORRESP
Explanation : Execution of the correspondence analysis. The 'plot(flip)' option transposes the graph axes. The 'w' variable is used for weighting, treating negative weights as supplementary data.
Copied!
proc corresp data=uspop print=percent observed cellchi2 rp cp chi2p
short plot(flip);
var y1920 -- y1970;
id Region;
weight w;
run;
1
PROC CORRESPDATA=uspop PRINT=percent observed cellchi2 rp cp chi2p
2
short plot(flip);
3
var y1920 -- y1970;
4
id Region;
5
weight w;
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.