Hi all,
Thanks, as ever, for the time and advice you all give here!
I have a dataset I've been working on, which I need to export for use in AirTable. Unfortunately, AirTable isn't great with multiple-choice responses so I need to concatenate some of the data.
The data below lists each type of Sustainable Development Goal that respondents have selected is relevant for their particular project. I need to combine each response into a new variable (sdgvar). But, I'd like to be able to export the new variable with the labelled values and not the numbers (as this will be how users interact with the data in AirTable).
Currently, I'm running: egen sdgvar = concat(newsdg2*), punct(,)
Which correctly concatenates all of the variables into one - but also includes the missing variables. Is there a way to:
Thanks in advance! And code from the file is below.
Thanks, as ever, for the time and advice you all give here!
I have a dataset I've been working on, which I need to export for use in AirTable. Unfortunately, AirTable isn't great with multiple-choice responses so I need to concatenate some of the data.
The data below lists each type of Sustainable Development Goal that respondents have selected is relevant for their particular project. I need to combine each response into a new variable (sdgvar). But, I'd like to be able to export the new variable with the labelled values and not the numbers (as this will be how users interact with the data in AirTable).
Currently, I'm running: egen sdgvar = concat(newsdg2*), punct(,)
Which correctly concatenates all of the variables into one - but also includes the missing variables. Is there a way to:
- Concatenate all of the labels (perhaps by re-stringing)?
- Drop any missing values when concatenating?
- Response 1: SDG 17
- Response 2: SDG 5, SDG 10
- Response 3: SDG 17
- Response 4: SDG 3, SDG 5, SDG 6, etc.
Thanks in advance! And code from the file is below.
Code:
* Example generated by -dataex-. For more info, type help dataex clear input byte(newsdg21 newsdg22 newsdg23 newsdg24 newsdg25 newsdg26 newsdg27) 17 . . . . . . 5 10 . . . . . 17 . . . . . . 3 5 6 7 11 13 . 5 7 9 10 13 . . 3 . . . . . . 3 10 . . . . . 3 . . . . . . 3 10 . . . . . 3 . . . . . . 17 . . . . . . 17 . . . . . . 10 . . . . . . 10 . . . . . . 3 7 8 10 . . . 5 . . . . . . 3 5 17 . . . . 5 . . . . . . 3 17 . . . . . 3 . . . . . . 3 5 7 8 10 13 17 17 . . . . . . 5 7 8 10 . . . 17 . . . . . . 5 . . . . . . 8 17 . . . . . 8 16 17 . . . . 9 10 . . . . . 10 . . . . . . 3 8 . . . . . 5 . . . . . . 1 . . . . . . 1 . . . . . . 1 . . . . . . 9 16 . . . . . 1 5 9 10 13 . . 1 5 10 13 . . . 1 5 10 17 . . . 5 6 . . . . . 17 . . . . . . 17 . . . . . . 7 11 . . . . . 9 . . . . . . 4 . . . . . . 8 9 11 . . . . 1 10 11 . . . . 10 11 . . . . . 1 10 . . . . . 10 . . . . . . 3 . . . . . . 4 8 11 17 . . . 17 . . . . . . 3 . . . . . . 3 . . . . . . 3 . . . . . . 10 . . . . . . 3 . . . . . . 3 . . . . . . 1 4 5 10 12 . . 10 . . . . . . 11 13 . . . . . 3 . . . . . . 1 8 . . . . . 16 . . . . . . 5 10 17 . . . . 9 10 17 . . . . 3 5 10 . . . . 10 17 . . . . . 5 9 10 11 16 17 . 16 . . . . . . 16 . . . . . . 16 . . . . . . 16 . . . . . . 16 . . . . . . 16 . . . . . . 16 . . . . . . 16 . . . . . . 16 . . . . . . 1 5 8 9 10 16 17 2 3 10 . . . . 17 . . . . . . 3 5 8 10 17 . . 8 . . . . . . 8 9 13 17 . . . 3 5 16 17 . . . 3 17 . . . . . 3 17 . . . . . 9 . . . . . . 5 10 13 . . . . 10 11 . . . . . 1 3 5 9 10 . . 10 . . . . . . 10 . . . . . . 1 5 10 16 . . . 5 9 10 . . . . 3 . . . . . . 3 5 . . . . . 2 3 4 16 . . . 3 . . . . . . 10 . . . . . . end label values newsdg21 sdg1label label values newsdg22 sdg1label label values newsdg23 sdg1label label values newsdg24 sdg1label label values newsdg25 sdg1label label values newsdg26 sdg1label label values newsdg27 sdg1label label def sdg1label 1 "1: No Poverty", modify label def sdg1label 2 "2: Zero Hunger", modify label def sdg1label 3 "3: Good Health and Well-being", modify label def sdg1label 4 "4: Quality Education", modify label def sdg1label 5 "5: Gender Equality", modify label def sdg1label 7 "7: Affordable and Clean Energy", modify label def sdg1label 8 "8: Decent Work and Economic Growth", modify label def sdg1label 9 "9: Industry, Innovation and Infrastructure", modify label def sdg1label 10 "10: Reduced Inequality", modify label def sdg1label 11 "11: Sustainable Cities and Communities", modify label def sdg1label 16 "16: Peace and Justice and Strong Institutions", modify label def sdg1label 17 "17: Partnerships to achieve the Goals", modify label def sdg1label 6 "6: Clean Water and Sanitation", modify label def sdg1label 13 "13: Climate Action", modify label def sdg1label 12 "12: Responsible Consumption and Production", modify
Comment