Home > Data Services > Catalog . Restricted Data . Census . ACS

Search Data Services

Meta Search
search across all the following databases:

Data Catalog
Data and documentation

KnowledgeBase
Common questions and answers.

Resources
Entire collection of data resources.


Latest Data News

RSS Feed icon

Lessons from North of the Border

Nerd Alert: Dictionary of Numbers

International Migration Statistics for the US

Open Data Executive Order

Measuring Marriage & Divorce among Same-Sex Couples

Summing Across Records

If the unit of analysis, say census tracts or zip codes, is broken into parts for some tracts or zip codes, these parts need to be combined if the unit of analysis is the census tract or zip code. For example, one might have the following data:

Tract    # of persons
1111        45
1111        50
2222        33
3333        15
3333        26
3333        31

For analysis purposes, the user needs the data to look like this:

Tract   # of persons
1111        95
2222        33
3333        72

The following program sums across IDs and then deletes all but one record per ID.

data a;
infile '/usr/work/gli/test.dat';
input id a;
proc sort data=a; by id;
run;
proc means noprint data=a;
by id;
var a;
output out=sum sum(a)=ax;
run;
data new;
   merge a sum(keep=id ax);
run;
proc print;
var id a ax;
proc sort nodupkey; by id;
proc print;
var id ax;
run;