Hi Statalisters,
I have a collapse/gen question. What you’ll observe in the dataset is a variable called DeclarationRequestDate which corresponds to a county, state, and fips code in each state from 2014-2019. What I need to do is create a county(sum) variable that counts the number of times a county-issued a Declaration Request during this time period. I need to retain the fips and the newly created count variable so that I can then merge with a master dataset (I know how to do this step). I think a collapse gen code is necessary but I’m not sure the correct sequence to generate a count variable and then identify the number of times a county requested a disaster declaration. Any assistance or tips are appreciated. A data example is provided so you can see the shape of the data.
I have a collapse/gen question. What you’ll observe in the dataset is a variable called DeclarationRequestDate which corresponds to a county, state, and fips code in each state from 2014-2019. What I need to do is create a county(sum) variable that counts the number of times a county-issued a Declaration Request during this time period. I need to retain the fips and the newly created count variable so that I can then merge with a master dataset (I know how to do this step). I think a collapse gen code is necessary but I’m not sure the correct sequence to generate a count variable and then identify the number of times a county requested a disaster declaration. Any assistance or tips are appreciated. A data example is provided so you can see the shape of the data.
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str30 sname str52 cname float(year fips) double DeclarationRequestDate "West Virginia" "Cabell" 2014 54011 19732.833333333336 "West Virginia" "Jackson" 2014 54035 19732.833333333336 "West Virginia" "Putnam" 2014 54079 19732.833333333336 "West Virginia" "Kanawha" 2014 54039 19732.833333333336 "West Virginia" "Roane" 2014 54087 19732.833333333336 "West Virginia" "Boone" 2014 54005 19732.833333333336 "West Virginia" "Clay" 2014 54015 19732.833333333336 "West Virginia" "Lincoln" 2014 54043 19732.833333333336 "West Virginia" "Logan" 2014 54045 19732.833333333336 "Oklahoma" "Le Flore" 2014 40079 19740 "Vermont" "Franklin" 2014 50011 19740 "Oklahoma" "Pushmataha" 2014 40127 19740 "Vermont" "Lamoille" 2014 50015 19740 "Vermont" "Grand Isle" 2014 50013 19740 "Vermont" "Chittenden" 2014 50007 19740 "Oklahoma" "Choctaw" 2014 40023 19740 "Vermont" "Orleans" 2014 50019 19740 "Vermont" "Caledonia" 2014 50005 19740 "Vermont" "Essex" 2014 50009 19740 "Pennsylvania" "Delaware" 2014 42045 19759.865972222222 "Pennsylvania" "Chester" 2014 42029 19759.865972222222 "Pennsylvania" "Lancaster" 2014 42071 19759.865972222222 "Pennsylvania" "Montgomery" 2014 42091 19759.865972222222 "Pennsylvania" "Philadelphia" 2014 42101 19759.865972222222 "Pennsylvania" "York" 2014 42133 19759.865972222222 "Pennsylvania" "Bucks" 2014 42017 19759.865972222222 "Georgia" "Henry" 2014 13151 19764 "Georgia" "Clayton" 2014 13063 19764 "Georgia" "Rabun" 2014 13241 19764 "Georgia" "Paulding" 2014 13223 19764 "Georgia" "Carroll" 2014 13045 19764 "Georgia" "Twiggs" 2014 13289 19764 "Georgia" "Candler" 2014 13043 19764 "Georgia" "Screven" 2014 13251 19764 "Georgia" "Fayette" 2014 13113 19764 "Georgia" "Polk" 2014 13233 19764 "Georgia" "Coweta" 2014 13077 19764 "Georgia" "Gordon" 2014 13129 19764 "Georgia" "Douglas" 2014 13097 19764 "Georgia" "Burke" 2014 13033 19764 "Georgia" "Forsyth" 2014 13117 19764 "Georgia" "Clarke" 2014 13059 19764 "Georgia" "Johnson" 2014 13167 19764 "Georgia" "Baldwin" 2014 13009 19764 "Georgia" "Oconee" 2014 13219 19764 "Georgia" "Emanuel" 2014 13107 19764 "Georgia" "Upson" 2014 13293 19764 "Georgia" "Butts" 2014 13035 19764 "Georgia" "Wilkinson" 2014 13319 19764 "Georgia" "Laurens" 2014 13175 19764 end format %td DeclarationRequestDate

Comment