Hello,
I am working with a longitudinal dataset which contains the following variables:
a.) temperature (varname: temp) collected at b.)various weather stations (varname: stationID) during c.)year XXX (varname: year) and in d.) county XX (varname: countyID).
For each year and for each county, I want to do the following: 1.) assign the mean temperature data from all of the weather stations within the county, 2.) find and assign to each county the minimum temp measured at a weather station in that county, and 3.) find and assign to each county the maximum temperature measured at a weather station in that county.
To find the mean temp, I used this command:
line 1: gen one=1
line 2: collapse (count) n_station=one (first) countyID ///
line 3: (mean) mean_temp=temp, by(countyID year)
but, similar code to find the minimum (line4) and maximum (line 5)don't work:
line 1: gen one=1
line 2: collapse (count) n_station=one (first) countyID ///
line 3: (mean) mean_temp=temp, by(countyID year)
line 4: (min) min_temp=temp, by(countyID year)
line 5: (max) max_temp=temp, by(countyID year)
Any suggestions on how I can fix this code?
Thank you
I am working with a longitudinal dataset which contains the following variables:
a.) temperature (varname: temp) collected at b.)various weather stations (varname: stationID) during c.)year XXX (varname: year) and in d.) county XX (varname: countyID).
For each year and for each county, I want to do the following: 1.) assign the mean temperature data from all of the weather stations within the county, 2.) find and assign to each county the minimum temp measured at a weather station in that county, and 3.) find and assign to each county the maximum temperature measured at a weather station in that county.
To find the mean temp, I used this command:
line 1: gen one=1
line 2: collapse (count) n_station=one (first) countyID ///
line 3: (mean) mean_temp=temp, by(countyID year)
but, similar code to find the minimum (line4) and maximum (line 5)don't work:
line 1: gen one=1
line 2: collapse (count) n_station=one (first) countyID ///
line 3: (mean) mean_temp=temp, by(countyID year)
line 4: (min) min_temp=temp, by(countyID year)
line 5: (max) max_temp=temp, by(countyID year)
Any suggestions on how I can fix this code?
Thank you
Comment