I am dealing with commodity-level price data. I have price data of around 800 commodities. Commodity variables are named according to their commodity codes. I want to label each variable. Data is given below.
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input float(wpi_1000000000 wpi_1100000000 wpi_1101000000 wpi_1101010000 wpi_1101010100 wpi_1101010101 wpi_1101010102)
101 97.7 97.7 100.9 101.4 101.2 100.8
101.1 97.5 97.6 101.2 102.1 102 101.1
101.4 98.1 97.9 101.3 102.2 102.1 100.8
102.7 99.1 100.4 100.6 101 102.5 95.8
102.5 98.9 100.3 100.9 101.2 102.5 96.1
102.9 101.1 102.3 103 103 104.3 98.1
104 104.6 106.5 105.4 104.7 105.7 100.3
104.1 105.2 106.2 106 105.1 106.7 100.6
104.9 105.8 106.7 106.5 105.4 107 101.3
105.4 107.5 109 107.7 106.5 107.6 103.5
105.5 108.2 109.9 108.5 106.3 106.6 104.7
104.9 105.3 105.5 109.4 106.7 105 107
105.4 106.1 106.7 112.6 110.3 104.9 116.7
105.6 105.5 106.1 113.4 111.3 105 119.4
105.7 104.3 105 113.1 110.4 105 116.7
107.8 106.7 106.4 112.9 109.1 105.6 111.6
108.7 108.4 108.3 114.9 110.8 106.4 114.4
109.9 111.3 111.8 116.6 111.9 107 116.3
110.8 112.5 112.2 116.6 111.8 107.3 115.9
111.5 114.5 114.9 117.8 112.9 107.8 119.1
end
I'm using the following code to label variables. It incorrectly labels all variables by the last item of the local variable. I guess we have to use another local inside the loop. Tried but not able to fix it.
Code:
local vars `""ALL COMMODITIES" "I PRIMARY ARTICLES" "(A) FOOD ARTICLES" "a. FOOD GRAINS(CEREALS+PULSES)" "a1. CEREALS" "Rice" "Wheat" "'
foreach x of varlist wpi_* {
foreach y of local vars{
label variable `x' "`y'"
}
}
0 Response to Variable labelling using loop
Post a Comment