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
country fixed effects or cluster standardised errors for cross-country analysisHello, i am doing a master thesis on the factors associated with help-seeking behavior of domestic v…
Generating percentiles for panel dataHello everyone, I am using panel data, with data per province per year/month for terrorist attacks.…
Rolling window Spearman correlationDear Stata Users, I want to generate a 5 year (min 3 years) rolling Spearman correlation. I have co…
mlogit Postestimation Stata 14 vs Stata 15 (bug?)Hello, Is anyone aware of changes Stata has made from v14 to v15 in terms of post-estimation (margi…
Generate a lead variable in a panelCross-posted on stack overflow. I need help in generating a lead variable in a panel. I want to ge…
Subscribe to:
Post Comments (Atom)
0 Response to remove certain string chars if in beginning of string var only
Post a Comment