How can I extract a substring between the nth and (n+1)th commas in a variable?
For example, consider ID = 3 and beta = "eight,nine,ten,eleven,twelve". How could I extract the substring between the 3rd and 4th commas? (Answer: "eleven")
Please note this is a vastly simplified example of an 80,000+ observation dataset where I have as many as 1,000 commas in an observation of the variable beta. I am using Stata 16.1 on Windows 10.
Many thanks!
For example, consider ID = 3 and beta = "eight,nine,ten,eleven,twelve". How could I extract the substring between the 3rd and 4th commas? (Answer: "eleven")
Code:
clear input ID strL beta 1 "one,two,three,four" 2 "five,six,seven" 3 "eight,nine,ten,eleven,twelve" end
Many thanks!
Comment