Quantcast
Channel: Statalist
Viewing all articles
Browse latest Browse all 73253

Adding Repetitive Lines in Accordance with the Number of Variables in a Program

$
0
0
I am writing a program that looks like:
:
prog def asp
syntax varlist [if] [in], flist(varlist)
tokenize `flist'
file open myfile using "File.csv", write replace

reg `varlist' `flist' if `touse'
file write myfile ",Coefficients of `1', t(`1') "  _n
file write myfile ", _b[`1'], _b[`1']/_se[`1']" _n
file close myfile
end
However, if I have two variables in the `flist', then I would not close myfile, and want to add
:
file write myfile ",Coefficients of `2', t(`2') "  _n
file write myfile ", _b[`2'], _b[`2']/_se[`2']" _n
file close myfile
end
Thus, the process should continue where the two lines are added for each additional variable in the `flist'. Right now I am using if statement, but cannot generlize it and cannot predict how many variables a user will add to the `flist'





Viewing all articles
Browse latest Browse all 73253

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>