{"id":544,"date":"2019-05-06T16:16:31","date_gmt":"2019-05-06T21:16:31","guid":{"rendered":"http:\/\/web.education.wisc.edu\/nwhillman\/?p=544"},"modified":"2019-05-06T16:16:31","modified_gmt":"2019-05-06T21:16:31","slug":"building-a-county-level-labor-force-and-unemployment-panel","status":"publish","type":"post","link":"https:\/\/web.education.wisc.edu\/nwhillman\/index.php\/2019\/05\/06\/building-a-county-level-labor-force-and-unemployment-panel\/","title":{"rendered":"Building a county-level labor force and unemployment panel"},"content":{"rendered":"<p>If you have ever looked for a way to get county-level unemployment rates for each county over time, there are probably a few ways to go about that task. Below is one way to do it in Stata.<\/p>\n<p><a href=\"http:\/\/web.education.wisc.edu\/nwhillman\/wp-content\/uploads\/sites\/16\/2019\/05\/stata_counties.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone  wp-image-545\" src=\"http:\/\/web.education.wisc.edu\/nwhillman\/wp-content\/uploads\/sites\/16\/2019\/05\/stata_counties-300x161.png\" alt=\"\" width=\"520\" height=\"279\" srcset=\"https:\/\/web.education.wisc.edu\/nwhillman\/wp-content\/uploads\/sites\/16\/2019\/05\/stata_counties-300x161.png 300w, https:\/\/web.education.wisc.edu\/nwhillman\/wp-content\/uploads\/sites\/16\/2019\/05\/stata_counties-768x413.png 768w, https:\/\/web.education.wisc.edu\/nwhillman\/wp-content\/uploads\/sites\/16\/2019\/05\/stata_counties-1024x550.png 1024w, https:\/\/web.education.wisc.edu\/nwhillman\/wp-content\/uploads\/sites\/16\/2019\/05\/stata_counties-624x335.png 624w, https:\/\/web.education.wisc.edu\/nwhillman\/wp-content\/uploads\/sites\/16\/2019\/05\/stata_counties-400x215.png 400w, https:\/\/web.education.wisc.edu\/nwhillman\/wp-content\/uploads\/sites\/16\/2019\/05\/stata_counties.png 1920w\" sizes=\"auto, (max-width: 520px) 100vw, 520px\" \/><\/a><\/p>\n<p>This copies each file from 2000 through 2018, saves and cleans it to your local machine, and then stacks them all together in a panel format. I haven&#8217;t fully spot-checked, so please let me know if you see bugs.<\/p>\n<p>Disclaimer: I have never figured out the whole Git Hub thing. I suspect if you&#8217;re reading this page there&#8217;s a good chance you haven&#8217;t either. So please don&#8217;t proselytize, just use this as a resource. WordPress doesn&#8217;t allow uploading .do files, but here&#8217;s what&#8217;s you could do:<\/p>\n<p>\/\/ set local directory<br \/>\ncd C:\\Users\\BLS_LAUS<\/p>\n<p>\/\/ copy data (2000 to 2018) from BLS website<br \/>\nlocal years 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18<br \/>\nforeach y of local years {<br \/>\nimport excel https:\/\/www.bls.gov\/lau\/laucnty`y&#8217;.xlsx<br \/>\nkeep if substr(A, 1, 2) == &#8220;CN&#8221;<br \/>\nrename A laus_code<br \/>\nrename B state_fips<br \/>\nrename C county_fips_3<br \/>\nrename D county_name<br \/>\nrename E year<br \/>\ndrop F<br \/>\nrename G labor_force<br \/>\nrename H employed<br \/>\nrename I unemployed<br \/>\nrename J unemp_rate<br \/>\nreplace labor_force = &#8220;&#8221; if labor_force==&#8221;N.A.&#8221;<br \/>\nreplace employed = &#8220;&#8221; if employed == &#8220;N.A.&#8221;<br \/>\nreplace unemployed = &#8220;&#8221; if unemployed==&#8221;N.A.&#8221;<br \/>\nreplace unemp_rate = &#8220;&#8221; if unemp_rate == &#8220;N.A.&#8221;<br \/>\ndestring year-unemp_rate, replace<br \/>\ngenerate str county_fips = state_fips + county_fips_3<br \/>\nsave county_20`y&#8217;.dta, replace<br \/>\nclear<br \/>\n}<\/p>\n<p>\/\/ append each year starting with 2000<br \/>\nuse county_2000.dta<br \/>\nforvalues y=2001\/2018 {<br \/>\nappend using county_`y&#8217;.dta<br \/>\n}<br \/>\nsave county_panel_2000_2018.dta, replace<\/p>\n<p>\/\/ table of total labor force, employed, and unemployed<br \/>\ntable year, c(sum labor_force sum employed sum unemployed) f(%20.0fc)<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you have ever looked for a way to get county-level unemployment rates for each county over time, there are probably a few ways to go about that task. Below is one way to do it in Stata. This copies each file from 2000 through 2018, saves and cleans it to your local machine, and [&hellip;]<\/p>\n","protected":false},"author":22,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_links_to":"","_links_to_target":""},"categories":[1],"tags":[],"class_list":["post-544","post","type-post","status-publish","format-standard","hentry","category-community-college-research"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/web.education.wisc.edu\/nwhillman\/index.php\/wp-json\/wp\/v2\/posts\/544","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/web.education.wisc.edu\/nwhillman\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/web.education.wisc.edu\/nwhillman\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/web.education.wisc.edu\/nwhillman\/index.php\/wp-json\/wp\/v2\/users\/22"}],"replies":[{"embeddable":true,"href":"https:\/\/web.education.wisc.edu\/nwhillman\/index.php\/wp-json\/wp\/v2\/comments?post=544"}],"version-history":[{"count":0,"href":"https:\/\/web.education.wisc.edu\/nwhillman\/index.php\/wp-json\/wp\/v2\/posts\/544\/revisions"}],"wp:attachment":[{"href":"https:\/\/web.education.wisc.edu\/nwhillman\/index.php\/wp-json\/wp\/v2\/media?parent=544"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/web.education.wisc.edu\/nwhillman\/index.php\/wp-json\/wp\/v2\/categories?post=544"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/web.education.wisc.edu\/nwhillman\/index.php\/wp-json\/wp\/v2\/tags?post=544"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}