Hi Statalist.
I'd like to create a dichotomous variable based on the title in the name of each individual in my dataset. The first category will contain all the people who have 'Associate Professor" or 'Professor' as the title of their name, and the second category will contain all the people who have 'Dr' (PhD) as the title of their name. I then wish to total all grant money (-grant2-) by the cat1 (e.g., professors) compared to that in cat2 (doctors/dr) for each year. Here's a sample of my data
I understand how to create a dichotomous variable, although I am not sure of the function I need to use to search titles from which to create the new variable - I tried using the following code[ - although Stata noted this is "invalid syntax".CODE]gen group = .
replace group = 1 if strstr(lead_investigator, "(Prof|A\/Prof|Asst Prof|Adj A/Prof|Adj/Prof|Em/Prof|Hon A/Prof|associate professor|professor)")
replace group = 2 if strstr(lead_investigator, "(dr|Dr|doctor)")[/CODE]I appreciate help with this. Regards, Chris (Stata SE 17.0).
I'd like to create a dichotomous variable based on the title in the name of each individual in my dataset. The first category will contain all the people who have 'Associate Professor" or 'Professor' as the title of their name, and the second category will contain all the people who have 'Dr' (PhD) as the title of their name. I then wish to total all grant money (-grant2-) by the cat1 (e.g., professors) compared to that in cat2 (doctors/dr) for each year. Here's a sample of my data
Code:
* Example generated by -dataex-. For more info, type help dataex clear input int grant_year strL grant_id long grant2 str1224 lead_investigator 2022 "10461" 5053012 "Prof an oh" 2021 "11608" 5050741 "A/Prof even att" 2020 "12773" 5037948 "Prof te ith-les" 2022 "10468" 5032188 "A/Prof tthias eusler" 2022 "10467" 5022681 "Prof eng ang" 2022 "10469" 5012184 "Prof ett ull" 2022 "10463" 4992796 "Prof dia rawska" 2017 "16317" 4991057 "Prof vid utens" 2022 "10462" 4983515 "A/Prof phie terme" 2020 "12776" 4971151 "Prof trick xton" 2008 "30025" 4901791 "Prof iguo an" 2014 "18887" 4894110 "Prof ngai ng" 2021 "11606" 4689777 "A/Prof en ng Lim" 2022 "10470" 4560617 "Prof rk askovich" 2016 "17626" 4552526 "Prof ent nro" 2013 "20275" 4541209 "A/Prof uart oy" 2017 "16306" 4486773 "Prof an oh" 2003 "39248" 4484676 "Prof mond rvis" 2017 "16302" 4336895 "Dr ean stone" 2019 "14925" 4320000 "Prof an ith" 2012 "22804" 4298513 "Dr von ue" 2015 "18644" 3795360 "Prof ianne illy-stra" 2023 "40792" 3776112 "A/Prof llip sey" 2023 "40788" 3772703 "Prof ander ilton" 2018 "15197" 3765289 "Prof mina bawa" 2019 "13952" 3458344 "Prof cela lek" end
replace group = 1 if strstr(lead_investigator, "(Prof|A\/Prof|Asst Prof|Adj A/Prof|Adj/Prof|Em/Prof|Hon A/Prof|associate professor|professor)")
replace group = 2 if strstr(lead_investigator, "(dr|Dr|doctor)")[/CODE]I appreciate help with this. Regards, Chris (Stata SE 17.0).
Comment