Let me focus on one detail implicit in the sequence of postings by
Martin Weiss on this subject.
As -foreach- can take a varlist, you can go directly to
foreach var of varlist t_* {
I can't see any advantage is using -ds- first in this example. The only
obvious reason for using -ds- would be as a filter to include (e.g.)
numeric variables only.
Nick
[email protected]
Michael McCulloch
Thanks Nick, what I meant more broadly was whether multiple date
variables, all whose names begin with "t_", for example t_date1,
t_date2, etc., could be specified in this line, in which the second
date is changed for a wider time frame:
> foreach var of varlist `r(varlist)'{
> gen byte seek`var' = `var' > td(1nov2009) & t_date <
td(9nov2009)
I also attempted a modification, which rather than giving me the id of
only records in which any date (t_*) was within 1nov to 9nov, instead
gave me all records and all dates:
qui ds t_*
sort id
foreach var of varlist `r(varlist)'{
gen byte seek`var' = `var' > td(1nov2009) & `var' < td(9nov2009)
list id seek* if `var'!=0
}
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/