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
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
Thanks you
0 Response to Create variables with loop
Post a Comment