I tried your suggestion Nick, but it works only for the dummies derived from
the last variable c3 and partially as the last label defined "cana" was
affected to all of the dummies.
I can't see why.
Here is the do file. Thank you.
Adama
version 7.0
use ctypes, clear
program define compo3
foreach var of local 0{
use ctypes, clear
sort id
local names1 "beans.... "
local names2 "Oelericultura..."
local names3 "Blackpepper....Cana"
local cropnames "`names1' `names2' `names3'"
local codes "`names1' `names2' `names3'"
local i = 1
foreach x of local cropnames {
local y : word `i' of `codes'
lab define `x' 1 "`y'" 0 "no", modify
capture forvalues j=1/46{
label val `var'_d`j' `x'
}
local i = `i' + 1
}
end
local area "c1 c2 c3"
foreach k of local area {
compo3 `k'
}
program drop compo3
exit
*
* 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/