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
post hoc for Fisher's exact testHello. Hope everyone is doing well. I would like to do a post hoc test after Fisher's exact test. I…
Assign value to a categorical variable between two limitsDear users, hope everyone is well. i want to assign value of 3 to the variable "dum" when the curre…
Counting Observations in Panel Data and filling in missing valuesHello everyone, I am new to STATA and have a question regarding the preparation of my Data sample. "…
Loop to merge multiple dta filesHi all, I am trying to run a loop to merge 10 files names year_1, year_2, ...., year_10 all at once…
Sensitivity testHello fellow stata users! I am in the midst of writing my bachelor thesis and I'm doing a cross-sec…
Subscribe to:
Post Comments (Atom)
0 Response to Sum up # of observations and output to spreadsheet/csv
Post a Comment