x cd /pub/data/popests/Tools; %let pgm=invoke_dosets_casrh; filename pgm "&pgm..sas";
/*
Invoke the %doset macro to create/delete observations in the Datasets dataset for the latest casrh datasets/
J. Blodgett, OSEDA, Aug. 2007 / 2008 / May 2009
Rerunning for 2013 data sets with fix involving the tilde character being wrong in some usage notes code.
Running for 2014.
Running after 2016 converts, 6/17--;
Running July 2019, GPR
Running December 2019 after adding CASRH 2018, GPR
*/
title "Job to Invoke doset Macro for casrh datasets in popests";
%include '/pub/sas/autoexec.sas';
options mprint nosymbolgen;
%let todo=;
libname popests '/pub/data/popests';
%let Byear=2020; *--base census year. Set to value of 2000 when doing data prior to 2011---;
%let cpsfx=1X; *-- convert program suffix. Set to yya for 2009 and earlier--;
%let Gyear=2023; %let yearp1= %eval(&Gyear + 1); %let gyr=%substr(&gyear,3,2);
*-- Make entries for earlier casrh datasets from previous year(s) disappear ;
data popests.datasets;
set popests.datasets;
if index(memname,"casrh04") then delete;
if index(memname,"casrh06") then delete;
if index(memname,"casrh11") then delete;
if index(memname,"casrh12") then delete;
if index(memname,"casrh13") then delete;
if index(memname,"casrh16") then delete;
if index(memname,"casrh17") then delete;
if index(memname,"casrh18") then delete;
if index(memname,"casrh19") then delete;
if index(memname,"casrh21") then delete;
if index(memname,"casrh22") then delete;
run ;
%let todolist=_template_casrh usstatescasrh&gyr us1dimsums_casrh&gyr ;
*-- This is a copy of the template defn in invoke_dosets. This one takes precedence but does not have to be run each year;
%doset(mode=,libname=popests,
memname=_template_casrh,
memlabel=%nrbquote(~stab county estimates by age, sex, race, hisp: ~Byear-~Gyear),
geouniv=~gstatenm,
units=county_asrht_demographic_combos,
Years=%str(~Byear-~Gyear),
CreatePgm=casrh_cnvt20~cpsfx,
Keywords=Population estimates county age sex race hispanic origin,
Description=%nrbquote(Estimates of the population of ~statenm counties for July 1 of each year from
~Byear to ~Gyear broken down by detailed age, sex, race, and hispanic origin.),
keyvars=sumtype county cbsa age sex race hispanic,
keyfmats=sumtype county cbsa age sex race hispani,
DataSource=%str(U.S. Bureau of the Census: FSCPE. Estimates released spring/summer, ~yearp1),
SortedBy=County,
UsageNotes=%nrbquote(
- Each row/obs in this dataset contains a time series of estimates for a specific combination of 4 demographic dimensions for a county. The demographic keys are age, sex, race and hispanic. When the value of one or more of these is blank, it means the summary does not involve that category. The SumType variable contains a string of up to four letters indicating what dimensions pertain. A value of 'ash', for example, indicates a summary by age, sex and hispanic origin (with race not considered.) A value of 'a' means data by age alone, with sex, race and hispanic not considered.
- A value of t for SumType indicates a total pop summary with no demographic detail.
- If you are looking for comparable state level data there is a usstatescasrh~gyr dataset in this (popests) data directory.
- Total pop and 1-dimensional summaries for all US counties are in the us1dimsums_casrh~gyr dataset.
- The key to understanding the codes is in the SAS value-labels code. Download this file to use as your codebook.
- The most recent metropolitan/micropolitan statistical area codes have been added.
- Note that to select sumtype values that have race-alone or multi-race summaries you have to select lower-case r, while race-alone-or-in-combination summaries are indicated by an upper-case R. When filtering on SumType enter a tilde (`) as the first character of your value to indicate that case matters. E.g. a filter of SumType Equal To `ar will select summaries by age and by the six race-alone categories (including the multi-race cat).
- To see the data in the format as originally released by the Census Bureau, look in the casrhalt&gyr subdirectory.
),
SubType=4casrh,
SetGroup=~stab,
VarSet=,
URLMeta=%str(https://mcdc.missouri.edu/cgi-bin/browse?/pub/data/popests/Tools/casrh_formats.sas@),
debug=0);
%macro doit(state,stab);
%let gstate=&state; %let gstab=&stab; %let gstatenm=&statenm;
%doset(libname=popests,memname=&stab.casrh&gyr,template=_template_casrh)
%mend doit;
%dostates(n=51,names=1);
%let stab=us;
%let statenm=UnitedStates;
options mprint;
%doset(libname=popests, memname=usstatescasrh&gyr,template=_template_casrh,
memlabel=%str(US state level estimates by age, sex, race, hispanic: &byear-&gyear),
geouniv=UnitedStates,
description=%nrbquote (Estimates of the population of U.S. states for July 1 of each year from &byear to &gyear broken down by detailed age, sex, race, and hispanic origin.),
keyvars=sumtype state age sex race hispanic,
keyfmats=sumtype state age sex race hispani,
units=State_asrht_combos,
UsageNotes=%nrbquote(- Each row/obs in this dataset contains a time series of estimates for a specific combination of 4 demographic dimensions for a state. This is just like the set of county level estimates, 1 per state, but here we have just 1 dataset for the country, with state summaries. There are no national totals here.
- The demographic keys are age, sex, race and hispanic. When the value of one or more of these is blank, it means the summary does not involve that category. The SumType variable contains a string of up to 4 letters indicating what dimensions pertain. A value of 'ash', for example, indicates a summary by age, sex and hispanic origin (with race not considered.) A value of 'a' means data by age alone, with sex, race and hispanic not considered.
- A value of t for SumType indicates a total pop summary with no demographic detail.
- If you are looking for comparable county level data see any of the SScasrh&gyr. datasets (where "SS" is a state) in this (popests) data directory.
- Total pop and 1-dimensional summaries for all US counties are in the us1dimsums_casrh&gyr. dataset.
- The key to understanding the codes is in the SAS value-labels code. Download this file to use as your codebook.
- Note that to select sumtype values that have race-alone or multi-race summaries you have to select lower-case r, while race-alone-or-in-combination summaries are indicated by an upper-case R. When filtering on SumType enter a tilde (`) as the first character of your value to indicate that case matters. E.g. a filter of SumType Equal To `ar will select summaries by age and by the 6 race-alone categories (including the multi-race cat).
- If you would prefer to see the data in the format as originally released by the Census Bureau, you can look in the casrhalt subdirectory.
),
debug=0) ;
%doset(libname=popests, memname=us1dimsums_casrh&gyr,template=_template_casrh,
geouniv=UnitedStates,
description=%nrbquote(County level summaries for entire US for total pop and single dimensions),
units=Counties_asrht1_combos,
keyvars=sumlev sumtype state county cbsa age sex race hispanic,
keyfmats=sumlev sumtype state county cbsa age sex race hispani,
UsageNotes=%nrbquote(- Each row/obs in this dataset contains a time series of estimates for a subpopulation based on a single demographic category (age, sex, race alone, race alone or in combination, hispanic) as well as total pop (SumType=t). It was created by taking all the observations in the county level datasets by state that had a 1-character SumType value and concatenating them in state/county order.
- A value of t for SumType indicates a total pop summary with no demographic detail.
- If you are looking for state level summaries there is a usstatescasrh~gyr dataset.
- The most recent metropolitan/micropolitan statistical area codes have been added to the observations in the variables CBSA and cbsatype.
- Note that to select sumtype values that have race-alone summaries you have to select lower-case r, while race-alone-or-in-combination summaries are indicated by an upper-case R. When filtering on SumType enter a tilde (~) as the first character of your value to indicate that case matters. E.g. a filter of SumType Equal To ~r will select summaries by the 5 race-alone categories and the single multi-race category.
),
subtype=4casrh2,
debug=0)
proc sort data=popests.datasets out=bysortprio; by sortprio; run;
proc datasets library=popests nolist;
modify datasets;
index delete dataset memname;
index create dataset=(libname memname) / unique;
index create memname;
quit;
options mprint msglevel=i;
%gendshtm(libname=popests,debug=1,runprocc=1,
sortby=descending sortprio setgroup memname, groupby=LatestYear);
/*<=========================Comment out=====================================
proc print data=allsets; by sortprio; *<--allsets is what us used by gendshtm macro to generate datasets.html ---;
var SetGroup Geouniv Subtype years Memname;
title2 "Variables Used to Order Entries in the Datasets.html page";
run;
===========================End commented out================================ */