/* Install packages related to reading in shape files */ ssc install spmap ssc install shp2dta ssc install mif2dta /* Read in the data that was produced using ArcGIS. Again, you will need to change the names of these datasets. */ foreach x in alameda contra_costa marin san_mateo san_francisco { shp2dta using intersect_`x', database(`x') coordinates(uscoord_`x') replace } use alameda, replace append using contra_costa append using marin append using san_mateo append using san_francisco ren * , lower destring intptl* statefp10-blockce10, replace replace contourele=contourele*.3048 /* Convert feet to meters */ /* Compute the max/min elevation by block */ bys state county tract blockce10 : egen elevationMax=max(contourele) bys state county tract blockce10 : egen elevationMin=min(contourele) gen diffWithinBlock=elevationMax-elevationMin /* Compute the maximum possible "distance" between any two points within the block. This approximation works under the assumption that blocks are near circular and that the max/min elevation within each block are at opposite ends of the block. */ gen diameter=2*sqrt((aland10+awater10)/3.1415) gen slope=diffWithinBlock/diameter bys _ID county: keep if _n==1 tabstat slope , stats(p10 p25 p50 p75 p90 N) by(county)