/**********************************************************************/ /* Program: NONEMP_HTML.SAS */ /* Written: October 16, 2001 */ /* Programmer: Edward Johnson */ /* User Specifications June 8, 2001 by Jerry Roth */ /* Programmer Specifications by Edward Johnson */ /* Last modifies August 12, 2003 - Rao Katikineni */ /* */ /**********************************************************************/ /**********************************************************************/ /* The purpose of this program is to create HTML pages for the */ /* Nonemployer publication using the Publication Source file */ /**********************************************************************/ libname d 'nls_cen19:[ec97.ec97x00.data]'; /*Pub Source Directory*/ libname s 'eap97_prod:[ec97.sharedata]'; /*DDS Shared Direcrory*/ proc copy in=d out=work; select nonemp01; /*For production change to NONEMP99*/ run; DATA nonemp01; set nonemp01 ; if xtab eq '001' and /*All types of establishments*/ rtype eq '01'; /*NAICS '01' is for public not BEA */ run; /*Use PROC SQL to create data sets of geographical areas for the pull downs.*/ proc sql; /*Create a dataset of states for each 2 digit NAICS code. This dataset shows which states have data for each 2 digit code. sector*/ create table stbynaic as select distinct geotype,st,sector, geo, abbr from nonemp01 where (estabf ne 'D' or ecvaluef ne 'D') and xtab eq '001' and (geotype = '1' or geotype eq '2'); /*Create a dataset of counties within each state which have data for each 2 digit NAICS code*/ create table county as select distinct geotype,st,county, geo, abbr from nonemp01 where (estabf ne 'D' or ecvaluef ne 'D') and xtab eq '001' and geotype = '3'; /*Create a dataset of MSA's (US level) which have data for each 2 digit NAICS code*/ create table msa as select distinct geotype,msa,geo from nonemp01 where (estabf ne 'D' or ecvaluef ne 'D') and geotype eq '6' and xtab eq '001' and (pmsa eq '9999' or pmsa eq '0000'); /*Create a dataset of PMSA's within each MSA which have data for each 2 digit NAICS code*/ create table pmsa as select distinct geotype,csa,pmsa,geo from nonemp01 where (estabf ne 'D' or ecvaluef ne 'D') and (geotype eq '6') and (xtab eq '001') and (pmsa ne '9999'); quit; proc sort data=stbynaic; by sector st; run; proc sort data=county; by st county; run; proc copy in=s out=work; select msabyst; run; proc sort data=msabyst; by st msa; run; proc sort data=msa; by msa; run; proc sort data=pmsa; by csa pmsa; run; /* Convert the SAS Data Set STBYNAIC into a text file which contains a HTML form which can be copied into a later HTML file to allow the user to select a specifc state. These files contain the HTML source for pull downs to show which states have data for each sector. This is needed because of the difficulty that SAS has in reading a second SAS data set while processing a first.*/ data _null_; length outline $ 150 website $ 44 fname $ 80; retain fname; set stbynaic; by sector st; if first.sector then do; fname = 'sys_temp:[ec97.htmlwork]sector' || sector || '.inc'; file a filevar=fname; end; file a filevar=fname; if sector eq '00' then do; website='/epcd/nonemployer/2001/'; outline = ''; put outline; end; else do; website='/epcd/nonemployer/2001/'; outline = ''; put outline; end; run; /* Convert the SAS Data Set COUNTY into a text file containing a HTML form which can be copied into a later HTML file to allow the user to select a specifc county within a state. These files contain the HTML source for pull downs to show which counties have data for each sector. This is needed because of the difficulty that SAS has in reading a second SAS data set while processing a first.*/ data _null_; length outline $ 150 website $ 44 fname $ 80; retain fname stname; set county; by st county; if first.st then do; fname = 'sys_temp:[ec97.htmlwork]state' || st || '.inc'; file a filevar=fname; end; file a filevar=fname; website='/epcd/nonemployer/2001/'; outline = ''; put outline; run; /* Convert the SAS Data Set MSABYST into a text file containing a HTML form which can be copied into a later HTML file to allow the user to select a specifc Metropolitan area within a state. These files contain the HTML source for pull downs to show which metro areas within each state have data for each sector. This is needed because of the difficulty that SAS has in reading a second SAS data set while processing a first.*/ data _null_; length outline $ 150 website $ 44 fname $ 80; retain fname; set msabyst; by st msa; if first.st then do; fname = 'sys_temp:[ec97.htmlwork]msast' || st || '.inc'; file a filevar=fname; end; file a filevar=fname; website='/epcd/nonemployer/2001/'; outline = ''; put outline; run; /* Convert the SAS Data Set MSA into a text file containing a HTML form which can be copied into a later HTML file to allow the user to select a specifc Metro area of the United States. These files contain the HTML source for pull downs to show which metropolitan areas have data for each sector. This is needed because of the difficulty that SAS has in reading a second SAS data set while processing a first.*/ data _null_; length outline $ 150 website $ 44 fname $ 80 ; retain fname; set msa; by msa; if _n_ eq 1 then do; fname = 'sys_temp:[ec97.htmlwork]allmsa.inc'; file a filevar=fname; end; file a filevar=fname; website='/epcd/nonemployer/2001/'; outline = ''; put outline; run; /* Convert the SAS Data Set PMSA into a text file containing a HTML form which can be copied into a later HTML file to allow the user to select a specifc PMSA within a MSA. These files contain the HTML source for pull downs to show which PMSA's within each CSA have data for each sector. This is needed because of the difficulty that SAS has in reading a second SAS data set while processing a first.*/ data _null_; length outline $ 150 website $ 44 fname $ 80; retain fname; set PMSA; by csa pmsa; if first.csa then do; fname = 'sys_temp:[ec97.htmlwork]csa' || csa || '.inc'; file a filevar=fname; end; file a filevar=fname; if pmsa ne '0000' and pmsa ne '9999' then do; website='/epcd/nonemployer/2001/'; outline = ''; put outline; end; run; proc sort data=nonemp01; by st county msa pmsa geotype sector naics; run; /**************************************************************************/ /*Create a separate HTML page for each state, county, msa, pmsa sector combination. Also, write a record to the NAICSUMM dataset every time the 2 digit naics changes so that a HTML page can be created showing ALL 2 digit NAICS for each Geographic area. */ /**************************************************************************/ data naicsumm(drop=line ind_det curdate); length fname infname allsect $ 50 line $150 ind_det $13 curdate 8 f $ 60 s $ 60 statenam $ 80 temptext $ 200 dwarrow $ 3 savenaics $ 8 saveind $ 107 saveest 8 saveestf $1 saveec 8 saveecf $1; retain fname statenam allsect dwarrow savenaics saveind saveest saveestf saveec saveecf; set nonemp01; by st county msa pmsa geotype sector naics; file 'sys_temp:[ec97.htmlwork]nonemp.html'; if sector eq '00' then output; else do; if first.sector then do; dname='sys_temp:[ec97.htmlwork]'; if geotype eq '6' then if pmsa ne '0000' and pmsa ne '9999' then do; fname = 'metro' || substr(pmsa,1,1) || '/M' || pmsa || '_' || sector || '.HTM'; allsect = 'M' || pmsa || '.HTM'; end; else do; fname = 'metro' || substr(msa,1,1) || '/M' || msa || '_' || sector || '.HTM'; allsect = 'M' || msa || '.HTM'; end; else do; fname = lowcase(abbr) || '/' || upcase(abbr) || county || '_' || sector || '.HTM'; allsect = upcase(abbr) || county || '.HTM'; end; put 'FILE ' fname; put ''; put '
'; put ''; put ''; put ''; put ''; put '';
put '';
put 'NAICS Code'; put ' | ';
put ' ';
put ''; put ''; put 'Description'; put ' | '; put ' '; put ''; put ' Nonemployers'; put ' | '; put '|
---|---|---|---|
';
put '
Establish- ments'; put ' | ';
put ' ';
put '';
put '
Receipts ($1,000)'; put ' | ';
put '||
'; put boldtxt; put naics; put ' | '; put ' '; put ''; put ''; put boldtxt; line = ''; put line; put industry; put ' | '; put ' '; put ''; put ''; put boldtxt; if estabf ne ' ' then do; put estabf; end; else do; put estab comma12.; end; put ' | '; put ' '; put ''; put ''; put boldtxt; if ecvaluef ne ' ' then do; put ecvaluef; end; else do; put ecvalue comma12.; end; if (dash eq '-') or (nl eq 2) or (nl eq 3) then do; put ''; end; end; /* (naics eq prevnaics)(industry eq prevind)(estab eq prevest)(ecvalue eq preveval) */ /* reset the variables to check for duplicate lines */ a="1"; prevnaics=naics||trim(a); prevind=industry; prevest=estab; preveval=ecvalue; put ' | '; put '
Top | '; put 'All-sector table | '; put 'Data in formats for downloading'; put ' | '; put '';
put '
| ';
put '
Page Generated ' curdate worddate18. ;
put ' ';
if substr(fname,1,5) ne 'metro' then
do;
mailto =
'Questions?';
put mailq;
end;
if substr(fname,1,5) eq 'metro' then
do;
mailto =
'Questions?';
put mailq;
end;
put '
';
put '
'; put ''; put ''; put ''; end; /*If last sector*/ end; /*if sector ne '00'*/ run; proc sort data=naicsumm; by st county msa pmsa geotype sector naics; run; data _null_; length fname infname $50 line $150 ind_det $13 curdate 8 f $ 60 s $ 60 statenam $ 80 temptext $ 200; retain fname statenam; set naicsumm; by st county msa pmsa geotype sector naics; file 'sys_temp:[ec97.htmlwork]nonemp.html' mod; if first.pmsa then do; dname = 'sys_temp:[ec97.htmlwork]'; if geotype eq '6' then if pmsa ne '0000' and pmsa ne '9999' then fname= 'metro' || substr(pmsa,1,1) || '/M' || pmsa || '.HTM'; else fname= 'metro' || substr(msa,1,1) || '/M' || msa || '.HTM'; else fname= lowcase(abbr) || '/' || upcase(abbr) || county || '.HTM'; put 'FILE ' fname; put ''; put '
'; put ''; put ''; put ''; put ''; put ''
'More data | ';
put '';
put '';
put 'NAICS Code'; put ' | ';
put ' ';
put ''; put 'Description'; put ' | '; put ' '; put ''; put ' Nonemployers'; put ' | '; put '||
---|---|---|---|---|---|
';
put '
Establish- ments'; put ' | ';
put ' ';
put '';
put '
Receipts ($1,000)'; put ' | ';
put '||||
' temptext; put ' | '; end; else put ''; /*There is no "more" for sector '00' so create empty table cell*/ put ''; put ' | '; put naics; put ' | '; put ' '; put ''; put ''; line = ''; put line; put industry; put ' | '; put ' '; put ''; put ''; if estabf ne ' ' then do; put estabf; end; else do; put estab comma12.; end; put ' | '; put ' '; put ''; put ''; if ecvaluef ne ' ' then do; put ecvaluef; end; else do; put ecvalue comma12.; end; put ' | '; put '
Top | '; put 'Data in formats for downloading'; put ' | '; put '';
put '
| ';
put '
Page Generated ' curdate worddate18.;
put ' ';
if substr(fname,10,2) = '81' then
do;
mailto =
'Questions?';
put mailq;
end;
if substr(fname,14,2) = '81' then
do;
mailto =
'Questions?';
put mailq;
end;
put '
';
put '
'; put ''; put ''; put ''; end; run; /*create inc file for year pull down in detail page and summary page*/ /*elimated duplicate value in sector 81*/ /*************************************************************************/ /** Rao Katikinenei : Modification on July 25, 2003 disbaling code below */ /** due to malfunctioning only one row is being returned */ /** **********************************************************************/ /* proc sql; */ /* create table ypddata as */ /* select distinct fname,allsect from naicsumm */ /* quit; */ /* alternate code below */ proc sort data=naicsumm out=ypddata nodupkey; by fname allsect; run; /*create dataset named ypddata to include year pull down*/ data ypddata; /*new dataset to create year pull down*/ set ypddata; if fname = " " then delete; /*first obs is blank then delete*/ yfile = scan (fname, -1, "/"); /*MD000_11.HTM*/ stfile = scan(fname, 1, "/"); /*md*/ run; proc sort data=ypddata; /*sort by MD000_11.HTM, MD000_21.HTM*/ by yfile; run; /*create inc file for year pull down for detail pages*/ data _null_; length yinc $ 150 website $ 44 ytext $ 85; retain ytext; set ypddata; by yfile; /* open new consolidated file to hold all ypd*.inc files */ file 'sys_temp:[ec97.htmlwork]nonempypd.inc'; ylength = length(trim(yfile)); /*MD000_11.HTM = length of fname*/ yfile = substr(yfile,1,ylength-4); /*MD000_11 = take out .htm*/ /*************************************************************************/ /** Rao Katikinenei : Modification on July 29, 2003 disabling code below */ /** and write all ypd*.inc to a single file */ /** **********************************************************************/ /*example inc file locates in sys_temp:[ec97.htmlwork]ydpMD000_11.inc ydp stands for year in detail page*/ /* do; */ /* ytext = 'sys_temp:[ec97.htmlwork]ydp' || trim(yfile) || '.inc'; */ /* file a filevar=ytext; */ /* end; */ /* file a filevar=ytext; */ ytext = 'ydp' || trim(yfile) || '.inc'; /* new code below */ put 'FILE ' ytext; website='/epcd/nonemployer/2001/'; yinc = ''; website='/epcd/nonemployer/2000/'; yinc = ''; website='/epcd/nonemployer/1999/'; yinc = ''; website='/epcd/nonemployer/1998/'; yinc = ''; website='/epcd/nonemployer/1997/'; yinc = ''; run; /*create inc file that contains the HTML source for year pull down in summary page*/ proc sort data=ypddata; by allsect; run; data _null_; length yinc $ 150 website $ 44 ystext $ 85; retain ystext; /*ystext for summary page*/ set ypddata; by allsect; /* open new consolidated file to hold all ysp*.inc files */ file 'sys_temp:[ec97.htmlwork]nonempysp.inc'; ylength = length(trim(allsect)); /*length of allsect = M0040.HTM*/ yfile = substr(allsect,1,ylength-4); /*take out .HTM = M0040 */ /*************************************************************************/ /** Rao Katikinenei : Modification on July 29, 2003 disbaling code below */ /** and write all ysp*.inc to a single file */ /** **********************************************************************/ /*example inc file locates in sys_temp:[ec97.htmlwork]yspM0040.inc ysp stands for year in summary page*/ /* if first.allsect then */ /* do; */ /* ystext = 'sys_temp:[ec97.htmlwork]ysp' || trim(yfile) || '.inc'; */ /* file a filevar=ystext; */ /* end; */ if first.allsect then do; ystext = 'ysp' || trim(yfile) || '.inc'; put 'FILE ' ystext; website='/epcd/nonemployer/2001/'; yinc = ''; website='/epcd/nonemployer/2000/'; yinc = ''; website='/epcd/nonemployer/1999/'; yinc = ''; website='/epcd/nonemployer/1998/'; yinc = ''; website='/epcd/nonemployer/1997/'; yinc = ''; end; run;