I have a dataset with four variables. One variable is string. Some of the observations within this variable have these characters at the end: [D], [E], [F], and so on. I want to identify rows where these characters occur. An example of my dataset:
Rows 13 and 19 are two examples of such rows. I have tried these fixes from ChatGPT:
gen uppercat = regexm(categories, "\\[.*\\]")
gen uppercat = regexm(categories, "\\[.\\]")
None of these work. This might be a very simple question, but I cannot find the answer.
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float line str180 categories str18 b str1 mainsector 13 "Cereals and bakery products [D]" "" "." 14 "Mean" "712" "." 15 "SE" "15.3" "." 16 "RSE" "2.15" "." 17 "Percent Reporting" "67.5" "." 18 "" "" "." 19 "Cereals and cereal products [D]" "" "." 20 "Mean" "214.98" "." 21 "SE" "6.08" "." 22 "RSE" "2.83" "." 23 "Percent Reporting" "40.66" "." end
Rows 13 and 19 are two examples of such rows. I have tried these fixes from ChatGPT:
gen uppercat = regexm(categories, "\\[.*\\]")
gen uppercat = regexm(categories, "\\[.\\]")
None of these work. This might be a very simple question, but I cannot find the answer.
Comment