I have a pretty large dataset where one of the columns has over 1200 unique observations. Each of these is a string variable with blanks. For example: in column titled "test", an observation is the following string "The Sun of Winter". I want to loop through the levels of "test" and generate a new variable called success_test where the earlier string is replaced by "The_Sun_of_Winter". I tried to loop through levels of test and use subinstr, and separately tried using sieve but to no avail.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str79 test long number double avg_days float "hear me roar" 143 43.92857142857143 "Winter is Coming" 121 27.4 "Fire and Blood" 77 14.25 "First in Battle" 68 34 "Growing Strong" 42 59 "We Do Not Sow" 189 121
0 Response to Replace Blanks within a String
Post a Comment