Hi,
the following dataset consists of numbers in a string format that are either separated by a comma (,) or a dot (.). For every variable, I would like to create a sum variable which counts the number of numbers that appear in this variable.
Example:
For the first observation every sum variable should take on 0 except the sum variables for AcqPRitself and IM_ER_neut. In these two cases, the sum variables should take on the value 1 because each one contains 1 number.
In the third observation, the sum variables of AcqPRitself and IM_hiring should take on the value 1. The sum variable for IM_new_prod has to equal 2, as two numbers (7 and 34) appear here. All other sum variables should equal 0.
Is there an easier way than using the split command for every variable?
Thanks in advance
the following dataset consists of numbers in a string format that are either separated by a comma (,) or a dot (.). For every variable, I would like to create a sum variable which counts the number of numbers that appear in this variable.
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str3 AcqPRitself str1 IM_ER_pos str5 IM_ER_neut str1(IM_ER_neg IM_EG_pos) str2 IM_EG_neut str1(IM_EG_neg IM_Div_pos) str3 IM_Div_neut str1 IM_Div_neg str3 IM_SEO str5 IM_Conference str4 IM_Sh_Meeting str1 IM_hiring str14 IM_new_prod "4" "" "5" "" "" "" "" "" "" "" "" "" "" "" "" "1" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "9" "" "" "" "" "" "" "" "" "" "" "" "" "8" "7.34" "1" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "4" "" "" "" "" "" "" "" "" "" "" "6" "" "" "" "2" "" "" "" "" "" "" "" "" "" "1" "" "" "" "" "10" "" "" "" "" "" "" "" "" "" "" "" "" "" "12" "1" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "3" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "2" "" "3,4,5" "" "" "" "" "" "3,8" "" "" "" "5" "" "" "2" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "1" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "2" "" "3" "" "" "" "" "" "" "" "" "" "" "" "" "1" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "7" "" "8" "" "" "" "" "" "" "" "" "" "" "" "" "3" "" "5" "" "" "" "" "" "4" "" "" "" "" "" "" "3" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "5" "" "4" "" "" "" "" "2" "" "" "" "" "" "" "3.1" "2" "" "1" "" "" "" "" "" "" "" "" "" "" "" "" "3" "" "" "" "" "" "" "" "" "" "" "" "4" "" "" "5" "" "6" "" "" "" "" "" "" "" "" "" "" "" "" "2" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "3" "" "6" "" "" "" "" "" "" "" "" "" "" "" "" "14" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "3" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "2" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "3" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "20" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "4" "" "" "" "" "" "" "" "" "" "" "" "5" "" "" "1" "" "" "" "" "" "" "" "" "" "" "" "" "" "" end
Example:
For the first observation every sum variable should take on 0 except the sum variables for AcqPRitself and IM_ER_neut. In these two cases, the sum variables should take on the value 1 because each one contains 1 number.
In the third observation, the sum variables of AcqPRitself and IM_hiring should take on the value 1. The sum variable for IM_new_prod has to equal 2, as two numbers (7 and 34) appear here. All other sum variables should equal 0.
Is there an easier way than using the split command for every variable?
Thanks in advance
Comment