foreach c in f s a u b {
gen `c' = substr(market,1,1) == "`c'"
}
More generally,
gen firstchar = substr(market,1,1)
levels firstchar, local(chars)
foreach c of local chars {
gen `c' = firstchar == "`c'"
}
Nick
[email protected]
Tumur Gunchinmaa
> I have another
> question to ask about creating dummy.
> I have a string variable called market (in the long format) which has
> 19 different string "values" such as
> f1,f2,...f6,s1,...,s5,a1,...,a5,u1,u2,b1.
> I would like to create 5 dummies which would group f1-f6 into
> dummy f, s1-s5 into dummy s, a1-a5 into dummy a and so on.
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/