Dear Stata forum members,
I have the following data structure, where I need to create new variables that count the number of different targets being addressed by specific NTMs. The variable (Linked_Target_*) holds the information for both, SDG Target and NTM code. The portion in the middle represents the SDG target: 3_4, 12_4, 12_5; whereas the end of the name of the variables represents the NTM code: A210, A220, B310.
I need to generate a new variable "SDG_Targets" that counts the number of specific SDG targets being addressed, so, in this case, it would be equal to 3, since there are three unique SDG Targets being addressed: 3_4 (2 times), 12_4 (1 time); 12_5 (1 time)
Note: The data is just a simple subsample of a large dataset, with +500 variables, for 10 years, and 7 sectors.
Thank you for your help
George
I have the following data structure, where I need to create new variables that count the number of different targets being addressed by specific NTMs. The variable (Linked_Target_*) holds the information for both, SDG Target and NTM code. The portion in the middle represents the SDG target: 3_4, 12_4, 12_5; whereas the end of the name of the variables represents the NTM code: A210, A220, B310.
I need to generate a new variable "SDG_Targets" that counts the number of specific SDG targets being addressed, so, in this case, it would be equal to 3, since there are three unique SDG Targets being addressed: 3_4 (2 times), 12_4 (1 time); 12_5 (1 time)
Note: The data is just a simple subsample of a large dataset, with +500 variables, for 10 years, and 7 sectors.
Thank you for your help
George
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str4(reporter partner) str6 hs6 int year float(Linked_Target_3_2_A210 Linked_Target_3_4_A210 Linked_Target_3_4_A220 Linked_Target_3_4_B310 Linked_Target_3_7_B310 Linked_Target_12_4_B310 Linked_Target_12_5_B310 Row_Data) "DEU" "IDN" "151110" 2018 0 0 1 1 0 1 1 11 "DEU" "IDN" "151110" 2019 0 0 1 1 0 1 1 11 end
Comment