I have a bunch of serially placed variables: Q49_1_a-Q49_104_h. I am trying to label them such that the labels become something like the following:
Apple_Total_harvested
Apple_Total_consumed
Orange_Total_harvested
Orange_Total_consumed
Mango_Total_harvested
Mango_total_consumed
I have a lot more fruits and attributes for which I want to use the for loop to save my time. I have tried the following code which produced an "invalid syntax r(198)" error.
Any help will be highly appreciated.
Apple_Total_harvested
Apple_Total_consumed
Orange_Total_harvested
Orange_Total_consumed
Mango_Total_harvested
Mango_total_consumed
I have a lot more fruits and attributes for which I want to use the for loop to save my time. I have tried the following code which produced an "invalid syntax r(198)" error.
Code:
local fruits yam tomato beet onion pepper cabbage papaya carrot lettuce cassava beans maize others
local attributes Total_harvested Consumed Sold Bartered Stored Stored_in_PHC Lost_Due_to_Pest_or_During_Storage Others
unab vlist: Q49_1_a-Q49_104_h
local i=1
foreach f of local fruits {
foreach a of local attributes {
local var: word `i' of `vlist'
label `var' "'f'_`a'"
local ++i
}
}

Comment