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
Cut name variable into two variables to get casteHello I am trying to segregate the name variable into two separate name and caste variables. (The s…
how to use regexm to analyse string variablesDear All Can anyone help me in finding an easier way to categories open ended questions. an examp…
When to use logged / not logged variablesHi All, I am carrying out research for my bachelor thesis looking at the effect of gin consumption …
Sample size calculation using one sided test with power commandHello all, I am trying to run a test to determine the sample size where the outcome is proportions …
Abrreviate variable name Stata 15.1Hi all, I have updated my Stata installation from 13 to 15.1. It seems this new version does not use…
Subscribe to:
Post Comments (Atom)
0 Response to Sum up # of observations and output to spreadsheet/csv
Post a Comment