Hello, I have this data in Stata. I want to extract the month and year variables from a string variable. The first number before _ '' represents the year and the number after '' represents the month variable. Thank you.
----------------------- copy starting from the next line -----------------------
----------------------- copy starting from the next line -----------------------
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str7 month "2021_02" "2021_03" "2021_04" "2021_05" "2021_02" "2021_03" "2021_04" "2021_05" "2021_02" "2021_03" "2021_04" "2021_05" "2021_02" "2021_03" "2021_04" "2021_05" "2021_02" "2021_03" "2021_04" "2021_05" "2021_02" "2021_03" "2021_04" "2021_05" "2021_02" "2021_03" "2021_04" "2021_05" "2021_02" "2021_03" "2021_04" "2021_05" "2021_02" "2021_03" "2021_04" "2021_05" "2021_02" "2021_03" "2021_04" "2021_05" "2021_02" "2021_03" "2021_04" "2021_05" "2021_02" "2021_03" "2021_04" "2021_05" "2021_02" "2021_03" "2021_04" "2021_05" "2021_02" "2021_03" "2021_04" "2021_05" "2021_02" "2021_03" "2021_04" "2021_05" "2021_02" "2021_03" "2021_04" "2021_05" "2021_02" "2021_03" "2021_04" "2021_05" "2021_02" "2021_03" "2021_04" "2021_05" "2021_02" "2021_03" "2021_04" "2021_05" "2021_02" "2021_03" "2021_04" "2021_05" "2021_02" "2021_03" "2021_04" "2021_05" "2021_02" "2021_03" "2021_04" "2021_05" "2021_02" "2021_03" "2021_04" "2021_05" "2021_02" "2021_03" "2021_04" "2021_05" "2021_02" "2021_03" "2021_04" "2021_05" end
Comment