Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to split string variable names

    so i have a string variable like below:

    var1
    percent gdp: 1258
    current account: 1216
    exchange rate: 740

    I want to split them so i can have the text and the number separate.

    as in;

    var1 var2
    percent gdp 1258
    current account 1216
    exchange rate 740

    any help please?

  • #2
    Try this:
    Code:
    split var1, parse(":") gen(newvar)
    You may want to subsequently -destring- newvar2.

    In the future please use the -dataex- command to post example data. Run -ssc install dataex- to get it, and then run -help dataex- to read the simple instructions for using it. The data as posted would be cumbersome to import into Stata were that needed in order to try out some code to help you. When you use -dataex-, you make it possible for those who want to help you to create a perfectly faithful replica of your Stata data example with a simple copy/paste operation.

    Comment

    Working...
    X