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)
}
}