Published on :
Statistical CREATION_INTERNE

Correspondence Analysis: US Population 1920-1970

This code is also available in: Deutsch Español Français
Awaiting validation
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!
1title 'United States Population, 1920-1970';
2 
3DATA 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;
15 
16 label y1920 = '1920' y1930 = '1930' y1940 = '1940'
17 y1950 = '1950' y1960 = '1960' y1970 = '1970';
18 
19 IF region = 'Hawaii' or region = 'Alaska'
20 THEN w = -1000; /* Flag Supplementary Observations */
21 ELSE w = 1000;
22 
23 DATALINES;
24New England 7401 8166 8437 9314 10509 11842
25NY, NJ, PA 22261 26261 27539 30146 34168 37199
26Great Lakes 21476 25297 26626 30399 36225 40252
27Midwest 12544 13297 13517 14061 15394 16319
28South Atlantic 13990 15794 17823 21182 25972 30671
29KY, TN, AL, MS 8893 9887 10778 11447 12050 12803
30AR, LA, OK, TX 10242 12177 13065 14538 16951 19321
31Mountain 3336 3702 4150 5075 6855 8282
32Pacific 5567 8195 9733 14486 20339 25454
33Alaska 55 59 73 129 226 300
34Hawaii 256 368 423 500 633 769
35;
2 Code Block
SAS SYSTEM
Explanation :
Activation of the ODS Graphics system for generating statistical plots.
Copied!
1ods 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!
1PROC CORRESP DATA=uspop PRINT=percent observed cellchi2 rp cp chi2p
2 short plot(flip);
3 var y1920 -- y1970;
4 id Region;
5 weight w;
6RUN;
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.
Copyright Info : SAS SAMPLE LIBRARY