Hello,
I am trying to accumulate the number of observations for each dataset with a pattern of "consumers_YYYY_*". I was only able to "display" the number of observations. I wonder how we could "sum this up" and eventually make it as a csv for each year (i.e. two variables: one is # of observations for each year, the other is year). Thanks a lot!!
global DATA "C:\Users\90596\data"
cd "${DATA}"
foreach y of num 2004/2018 {
local files : dir "${DATA}" files "consumers_`y'*"
cd "${DATA}"
foreach file in `files' {
use ids using `file', clear
dis(_N)
}
}
Related Posts with Sum up # of observations and output to spreadsheet/csv
Returning the name of a variable that takes on the maximum value within a set of other variables?Hey folks. I have a dataset with respondents reporting how many visits they took to certain recreati…
multinomial logit questionI am trying to run a multinomial logit as y being the number of credit cards an individual has. I re…
Accounting for time difference in forecasts when using repeated cross sectional dataI need to forecast repeated cross sectional data (survey data) with (dep. var.) monthly electricity…
Interpreting a fixed effects regression whether the treatment variable is binaryHello all, There have been similar posts about this interpretation but I can't find any with the sa…
Taking a midpoint of quarterI have two numeric variables labeled quarter (1,2,3,4) and year. I want to generate a new variable t…
Subscribe to:
Post Comments (Atom)
0 Response to Sum up # of observations and output to spreadsheet/csv
Post a Comment