x cd /pub/data/cbp/Tools; %let pgm=invoke_dosets; filename pgm "&pgm..sas";
*---generate metadata = cbp.datasets for the county business patterns data collection.
See invoke_diosets2.sas for later definitions. jgb 2011. ------*;
*-----Run this step ONLY ONCE------------------------------------------;
*----If you need to rerun (start over) then delete the datasets dataset first. doset will not
allow initialize mode if the datasets set already exists.---;
%*doset(mode=initialize,
libname=cbp,debug=1);
*----------------------------------------------------------------------;
/* =======================Begin comment================
%doset(mode=,libname=cbp,
memname=_template_states,
memlabel=%nrstr(State level summaries for ~years),
geouniv=UnitedStates,
units=States,
Year=~years,
CreatePgm=cnvtyy_naics,
Keywords=state county business patterns employment industry naics wages,
Description=%nrbquote(Summary of business establishments by state, by size, by NAICS code for ~years.),
keyvars=state nlevel naics nlevel,
keyfmats=state | naics2_ | ,
keyquals=,
DataSource=%str(United States Census Bureau),
SortedBy=state naics,
UsageNotes=%nrbquote(
- Information on total establishments, total employees, annual and 1st quarter payrolls for the
specified state/NAICS (industry). Data is then repeated for businesses by size class: those employing 1 to 4 persons,
those employing 5 to 9, etc. Total employment and wage data are also reported by size category. But there is significant
suppression of some of these items to avoid disclosure.
- There is a summary for NAICS code '------' which means all industries and is "level 0". In general dashes or slashes
used within a NAICS code indicate the
level of the code. Code 11---- is considered a level 1 code, while code 113/// is considered a level 2 code.
- The variable Industry contains the same value as the varible naics.
But a format code is associated with it so that it displays as the name of the naics industry.
- These data were converted to SAS datasets by reading the ascii files provided on the cd-roms issued by the Census Bureau or
(starting with 2005 data) downloaded from the Bureau web site.
),
SetGroup=states,
VarSet=,
URLMeta=%str(http://www.census.gov/epcd/cbp/view/cbpview.html),
filters=,
debug=1)
%doset(mode=,libname=cbp,
memname=_template_uscos,
memlabel=%nrstr(County level summaries for ~years),
geouniv=UnitedStates,
units=Counties,
Year=~years,
CreatePgm=cnvtyy_naics,
Keywords=county business patterns employment industry naics wages,
Description=%nrbquote(Summary of business establishments by county for the entire U.S., by size,
by NAICS code (multiple levels) for ~years.),
keyvars=state county naics nlevel cbsa cbsatype cbsayr msacmsa pmsa ,
keyfmats=state county naics2_ | cbsa | | metro metro,
keyquals=,
DataSource=%str(United States Census Bureau),
SortedBy=state county naics,
UsageNotes=%nrbquote(- Information on total establishments, total employees, annual and 1st quarter payrolls for the
specified county / NAICS (industry). Counts of businesses by size class: those employing 1 to 4 persons, those employing
5 to 9, etc. At this level there is no wage or total employment reported at the employment-size level as there is with the state
and national data sets.
- There is a summary for NAICS code '------' which means all industries and is "level 0". In general dashes or slashes
used within a NAICS code indicate the
level of the code. Code 11---- is considered a level 1 code, while code 113/// is considered a level 2 code.
- The variable Industry contains the same value as the varible naics.
But a format code is associated with it so that it displays as the name of the naics industry.
- These data were converted to SAS datasets by reading the ascii files provided on the cd-roms issued by the Census Bureau or
(starting with 2005 data) downloaded from the Bureau web site.
),
SetGroup=counties,
VarSet=,
URLMeta=%str(http://www.census.gov/epcd/cbp/view/cbpview.html),
filters=,
debug=1)
%doset(mode=,libname=cbp,
memname=_template_ustots,
memlabel=%nrstr(National summaries for ~years),
geouniv=UnitedStates,
units=Nation,
Year=~years,
CreatePgm=cnvtyy_naics,
Keywords=county business patterns employment industry naics wages national totals,
Description=%nrbquote(Summary of business establishments for the nation, by size, by NAICS code for ~years.),
keyvars=naics nlevel,
keyfmats=naics02. | ,
keyquals=,
DataSource=%str(United States Census Bureau),
UsageNotes=%nrbquote(- Information on total establishments, total employees, annual and 1st quarter payrolls for the
specified NAICS (industry). Data is then repeated for businesses by size class: those employing 1 to 4 persons,
those employing 5 to 9, etc. Total employment and wage data are also reported by size category. But there is significant
suppression of some of these items to avoid disclosure.
- There is a summary for NAICS code '------' which means all industries and is "level 0". In general dashes or slashes
used within a NAICS code indicate the
level of the code. Code 11---- is considered a level 1 code, while code 113/// is considered a level 2 code.
- The variable Industry contains the same value as the varible naics.
But a format code is associated with it so that it displays as the name of the naics industry.
- These data were converted to SAS datasets by reading the ascii files provided on the cd-roms issued by the Census Bureau or
(starting with 2005 data) downloaded from the Bureau web site.
),
SortedBy=naics,
SetGroup=ustots,
VarSet=,
URLMeta=%str(http://www.census.gov/epcd/cbp/view/cbpview.html),
filters=,
debug=1)
*---------------OK, the templates are defined. Now just use them to create entries for each of the years--;
======================End comment================== */
options mprint;
%macro doyr(y);
%let yr=%substr(&y,3,2);
%if &y=1999 %then %doset(libname=cbp,memname=states&yr,template=_template_states,years=1999,debug=1) ;
%else %doset(libname=cbp,memname=states&yr,template=_template_states,years=&y,debug=1);
%doset(libname=cbp,memname=uscos&yr,template=_template_uscos,years=&y,debug=1) ;
%doset(libname=cbp,memname=states&yr,template=_template_states,years=&y,debug=1)
%doset(libname=cbp,memname=ustots&yr,template=_template_ustots,years=&y)
%mend doyr;
options mprint;
%doyr(2006)
;
/* =======================Begin comment================
%doyr(1999)
options nomprint;
%doyr(2000)
%doyr(2001)
%doyr(2002)
%doyr(2003)
%doyr(2004)
%doyr(2005)
%doset(mode=,libname=cbp,
memname=naics,
memlabel=,
geouniv=NA,
units=NAICS codes,
Year=,
CreatePgm=naics_codes,
Keywords=county business patterns industry older naics codes,
Description=%nrbquote(This is the set that gives you the codes, levels and names for each NAICS code. These are the codes
as used up to and including 2002 data. See naics2002 for the more current codes),
keyvars=naics,
keyfmats=naics,
keyquals=,
DataSource=%str(naicref.txt file on the 2001 CBP cd-rom),
SortedBy=naics,
UsageNotes=%nrbquote(- The naics2 variable ids the Major Industry Group
- See naicref.txt for source file used to create this set.
),
SetGroup=naicref,
VarSet=,
URLMeta=%str(http://www.census.gov/epcd/cbp/view/cbpview.html),
filters=,
debug=1)
%doset(mode=,libname=cbp,
memname=naics2002,
memlabel=,
geouniv=NA,
units=2002 NAICS codes,
Year=,
CreatePgm=naics_codes,
Keywords=county business patterns industry current naics codes,
Description=%nrbquote(This is the set that gives you the codes, levels and names for each NAICS code. These are the codes
as used ustarting with the 2003 data. See naics for the codes use in earlier years),
keyvars=naics,
keyfmats=naics2_,
keyquals=,
DataSource=%str(CBP section of Census Bureau web site.),
SortedBy=naics,
UsageNotes=%nrbquote(- The naics2 variable ids the Major Industry Group
- See naics2002.txt for source file used to create this set.
),
SetGroup=naicref,
VarSet=,
URLMeta=%str(http://www.census.gov/epcd/cbp/view/cbpview.html),
filters=,
debug=1)
%doset(mode=,libname=cbp,
memname=naics2,
memlabel=,
geouniv=NA,
units=NAICS major industry codes,
Year=,
CreatePgm=naics_codes,
Keywords=county business patterns major industry naics codes,
Description=%nrbquote(Major industry NAICS codes),
keyvars=naics2,
keyfmats=naics2_,
keyquals=,
DataSource=%str(naicref.txt file on the 2001 CBP cd-rom),
SortedBy=naics2,
UsageNotes=%nrbquote(- The value of naics2 is stored on the various datasets to ID the major industry assoicated with
the more detailed industry.
- Codes 32, 33, 45 and 49 are not used. We collapsed these into 31, 44 and 48.
),
SetGroup=naicref,
VarSet=,
URLMeta=%str(http://www.census.gov/epcd/cbp/view/cbpview.html),
filters=,
debug=1)
======================End comment================== */
proc sort data=cbp.datasets out=bysortprio ; by sortprio setgroup descending years; run;
proc print data=bysortprio;
by libname notsorted libpath ;
id memname;
var SortPrio SetGroup SubType VarSet URLmeta GeoUniv years ;
title2 'Listing of Selected Fields from cbp.datasets (Sorted by SortPrio)';
run ;
proc datasets library=cbp nolist;
modify datasets;
index delete dataset memname;
index create dataset=(libname memname) / unique;
index create memname;
quit;
options mprint msglevel=i;
%gendshtm(libname=cbp,debug=1,runprocc=1);
*---------------We generate some keyvals pages here because they time out trying to do it from the web--;
proc datasets library=cbp; *--we need indices so wgenkey can process these as sorted datasets--;
modify uscos&yr;
index create naics;
index create nlevel;
quit;
options mprint;
%global kv ki kq kf libname memname filetype sd ow sorted;
%let libname=cbp; %let filetype=cbp; %let sd=; %let ow=1;
%let sorted=1;
%let memname=uscos&yr;
%let kv=nlevel; %let kf=1;
%wgenkey;
%let kv=naics; %let kf=naics;
%wgenkey ;
%let memname=uscos&yr;
%let kv=nlevel; %let kf=1;
%wgenkey;