Hi, i would like to create some variables with loop.
I have 5 variables : switch1 / switch2 /.../ switch5 and i would like to create variables like that :
first_switch is the first switch that is not missing
second_switch is th second switch that is not missing (and there is a first)
third_switch is the third switch that is not missing (and there is a first and a second)




Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input float ID str4(switch1 switch2 switch3 switch4 switch5)
1 "" "W94" "W144" "W144" ""    
2 "" "" "W94"  "W144" ""    
3 "W94" "W144" "" "W192" ""    
4 "" "" "W144" "" "W192"
5 "W144" "" "W144" "" ""    
6 "" "" "" "W192" ""    
7 "W94" "" "" "W192" ""    
8 "W144" "" "" "" "W192"
9 "" "W144" "" "" "W192"
10 "" "" "W144" "W192" ""    
end
and i would like to get that :

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input float ID str4(switch1 switch2 switch3 switch4 switch5 first_switch second_switch third_switch)
1 "" "W94" "W144" "W144" "" "W94" "W144" "W144"
2 "" "" "W94" "W144" "" "W94" "W144" ""    
3 "W94" "W144" "" "W192" "" "W94" "W144" "W192"
4 "" "" "W144" "" "W192" "W144" "W192" ""    
5 "W144" "" "W144" "" "" "W144" "W144" ""    
6 "" "" "" "W192" "" "W192" "" ""    
7 "W94" "" "" "W192" "" "W94" "W192" ""    
8 "" "" "" "" "" "" "" ""    
9 "" "W144" "" "" "W192" "W144" "W192" ""    
10 "" "" "W144" "" "" "W144" "" ""    
end
Can i do it with a loop (i have so many values)?

Thanks you