Data example:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str102 title "Ghostbusters (1984 Original) (1984)" "Rio Bravo (1959)" "The Seventh Seal (Det Sjunde inseglet) (1957)" "The Lion King (1994)" "Deadpool 2 (2018)" "Back to the Future (1985)" "The Fugitive (1993)" "Crouching Tiger, Hidden Dragon (2001)" "The Searchers (1956)" "Bullitt (1968)" end
Code:
split title, p("(") gen(year) variables created as string: year1 year2 year3 year4 . split year2, p(")") variable created as string: year21
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str68 year1 str51 year2 str27 year3 str5 year4 str49 year21 "Black Panther " "2018)" "" "" "2018" "Avengers: Endgame " "2019)" "" "" "2019" "Mission: Impossible - Fallout " "2018)" "" "" "2018" "Mad Max: Fury Road " "2015)" "" "" "2015" "Spider-Man: Into the Spider-Verse " "2018)" "" "" "2018" "Wonder Woman " "2017)" "" "" "2017" "Logan " "2017)" "" "" "2017" "Coco " "2017)" "" "" "2017" "Dunkirk " "2017)" "" "" "2017" "Star Wars: The Last Jedi " "2017)" "" "" "2017" "Thor: Ragnarok " "2017)" "" "" "2017" "Seven Samurai (Shichinin no Samurai) " "Shichinin no Samurai) " "1956)" "" "1954" "Star Wars: Episode VII - The Force Awakens " "2015)" "" "" "2015" "Metropolis " "1927)" "" "" "1927" "Soul " "2020)" "" "" "2020" "The Adventures of Robin Hood " "1938)" "" "" "1938" "Spider-Man: Far From Home " "2019)" "" "" "2019" "Incredibles 2 " "2018)" "" "" end
Question: How should I edit codes to split the variable more accurately/without needing to make corrections manually?
This is my first time posting. I apologize in advance if I didn't use the Statalist function correctly.
Thank you very much for your help.
0 Response to Splitting String
Post a Comment