I am trying to calculate the daily mean of a variable contingent on various conditions. For example, if I have temperatures taken throughout the day at multiple locations, how can I get the daily temperature recorded at each location.
The main variables are date, temperature and some booleans for location such as isJFK, isCP etc.
For the entire data set, you can do
bysort date: egen dailymean = mean(temperature)
How can I get the daily temperature for one location
bysort date isJFK: egen dailycpmean = mean(temperature) does produces a new column of results but they don't seem to be daily temperature for JFK.
Related Posts with Bysort with generation of variable
How to count number of countries when you have individual-level data of many countriesHi, I need to fill in my descriptive statistic analysis sample, and thus I need to count the number…
Average of Previous (x) ObservationsGood morning, At the moment I need to calculate the average of the 3 previous nmfp for each horse. …
Count occurences of a dummy variable by ID in panel dataHi everyone, I am working with a panel data about the living conditions of individuals in different …
Estimating an hourly ATE in the DID frameworkDear Statalist, I am trying to estimate the average treatment effect for each hour of the day(0-23…
Marginal effects command doesn't work. Don't understand error: factor variables may not contain noninteger valuesHi! I'm doing a binary logistic regression in Stata 15.0, but my supervisor told me you cannot inte…
Subscribe to:
Post Comments (Atom)
0 Response to Bysort with generation of variable
Post a Comment