Dear Statalist,
I have been searching for ways to remove a sequence of characters from a string variable only if they appear in the beginning of the word, and I have not found a successful way to implement this.
My example data are as follows, with quotation marks added to make it clear where blanks are present in the string variable traintype:
obs traintype
1 " - Training on anesthesia machine - provider"
2 " - Training on anesthesia machine - trainer"
3 "Training on anesthesia machine - provider
4 "Training on anesthesia machine - trainer"
I would like obs 1&2 to appear as obs 3&4 however, I am unable to just replace the sequence " - " from the whole string because this would remove the sequence later in the variable that I want to maintain.
Thank you so much for considering this question.
Best,
Alison
Related Posts with remove certain string chars if in beginning of string var only
How to create overlapping spells as One eventDear Forum members, I am working on a panel dataset that contains more than 50,000 hospital records…
New package: Relogitplot - predictive margins plots after relogit regressionsIf you use the relogit package (Tomz, King, and Zeng), you may be interested in an addon I wrote whi…
Combining observationsHi statalist, I have a dataset with approx 1.000.000 observations. In my dataset I have a lot of du…
Removing individuals based on criteriaHi. I am working with paneldata. I want to remove individuals who don't have a value for each year …
Multiple sheets export excelHello, I want to export the "auto" file in several Excel's sheets (one per brand). Code: sysuse aut…
Subscribe to:
Post Comments (Atom)
0 Response to remove certain string chars if in beginning of string var only
Post a Comment