Hi ,
I want to generate the variable only up the condition of another variable

here,

local 38"phone"
local 39"Battery"
local 40"machine spare parts"
local 41"carpenter tools"
local 42"horse"
local 43"sound-box"
local 44"bamboo and"
local 45"box"
local 46"cement,zinc sheet"
local 47"chain saw"
local 48"motor"
local 49"water tank"
local 50"Tree"


forval n=38/50{
gen agriitem_pur_`n'=0 if itemoth1=="``n''"
}

Searching about local text, if there is that local text, want to generate that local number in agriitem_pur_`n'. If not, no need to generate, for example, if motor in itemoth1, generate agriitem_pur_38, otherwise, not need to generate that variable. But now generate all variable whether not find the local item.

Please sugest!