Data management: How to convert a string variable to a numeric variable

Поділитися
Вставка
  • Опубліковано 23 січ 2025

КОМЕНТАРІ • 55

  • @shashavengesayi6055
    @shashavengesayi6055 2 роки тому +1

    This UA-cam channel is literally a lifesaver for me in grad school, thanks.

  • @retcotz
    @retcotz 5 років тому +18

    If your data is stored as text say female and male and you want to make it numeric variable 1=Male 2=Female then follow the steps>Menu>Data>create or change data>other variable-transformation commands>Encode value labels from string variable> then choose source variable (string) and name your new numeric variable (gender2). It works so nice. I hope it helps

    • @letuananh7205
      @letuananh7205 5 років тому +2

      My case is: Variable X contains nonnumeric characters; no replace

    • @letuananh7205
      @letuananh7205 5 років тому +2

      Or second try: destring VarX, generate(VarX)
      VarX contains nonnumeric characters; no generate

  • @Non-disjunction
    @Non-disjunction 5 років тому +7

    For everyone where it didnt work:
    "If your data is stored as text say female and male and you want to make it numeric variable 1=Male 2=Female then follow the steps>Menu>Data>create or change data>other varaible-transformation commands>Encode value labels from string variable> then choose source variable (string) and name your new numeric variable (gender2). It works so nice. I hope it helps"
    Credits to ua-cam.com/channels/xyHocrrLQPd1SooIGH2sDQ.html

    • @MazDTdK
      @MazDTdK 4 роки тому

      Oh man I knew it and then I forgot and now your message saved me from unnecessary frustration. Thanks a lot!

    • @Non-disjunction
      @Non-disjunction 4 роки тому

      @@MazDTdK No problem dude. good luck with your work

    • @rumila372
      @rumila372 2 роки тому

      Thank you, this helped!!

    • @muhamadfarhan744
      @muhamadfarhan744 2 роки тому

      Thanks mate

  • @Economics365
    @Economics365 2 місяці тому

    Why not showing where's available the link on the website and how to put here

  • @gabri99grisel
    @gabri99grisel 7 років тому +22

    Hi, im working with stata right now. And i have tried with your steps, but it said "no generate". Can you help me with this problem? Thanks

    • @lourdesseminario9343
      @lourdesseminario9343 6 років тому +1

      Hello, i have the same problem, did you find any solution?

    • @10RNAPOE
      @10RNAPOE 6 років тому +2

      delete the commas, you can try excel first

    • @ThiriWinHtike
      @ThiriWinHtike 6 років тому +8

      I just checked the first box "Convert nonnumeric strings to missing values". then it replaced my bank cells with "." and it worked for me.

    • @mcdonalds1499
      @mcdonalds1499 6 років тому

      @@ThiriWinHtike wow cool, thanks. you saved me

    • @yusufmemic
      @yusufmemic 5 років тому

      deleting commas have worked, thanks :)

  • @dim7918
    @dim7918 2 роки тому

    Thank you so much sir!
    Short and Concise
    Really helpful!

  • @Emilytan5365
    @Emilytan5365 7 років тому +24

    I followed your guidance ... yet I cant convert it.
    destring credit_line, generate(credit)
    credit_line contains nonnumeric characters; no gene
    > rate

    • @MrRobertLake
      @MrRobertLake 5 років тому

      You probably have some missing observations indicated as missing data. As an example, your last obs might say NA. Then tell the command to exclude NA. The basic problem is that this function is written so extremely simple that typical time series problems.

    • @Non-disjunction
      @Non-disjunction 5 років тому +3

      @@MrRobertLake Same problem. Checkd the data, I have no missing observations.

    • @dibyajyotisinha6379
      @dibyajyotisinha6379 3 роки тому

      You need to use encode

    • @the-researcher
      @the-researcher 3 роки тому +1

      Use the 'force' option or use encode

    • @wuodtitochannel1678
      @wuodtitochannel1678 2 роки тому +3

      @@Non-disjunction Try this destring strVar, generate(numVar) force

  • @nextgengems
    @nextgengems 5 років тому

    Love your video. To the point and spot on. Keep up the great work :-)

  • @jabulanimathebula1472
    @jabulanimathebula1472 3 роки тому

    How do I convert categorical variable to continuous variable?

  • @jeanmarcelduarte5830
    @jeanmarcelduarte5830 3 роки тому

    Solved my problem, thank you very much!

  • @shafiqullahyousafzai15
    @shafiqullahyousafzai15 3 роки тому

    Thanks from Afghanistan

  • @marceloemanoel16
    @marceloemanoel16 5 років тому

    Thank you very much!!! Helped me a lot!!!!

  • @africansinportugal9046
    @africansinportugal9046 3 роки тому

    Thank you! This was helpful!

  • @tavoyreid4876
    @tavoyreid4876 5 років тому

    Do you know how to correct error 200 in STATA, that one that says no observations. If anyone in the comment knows please let me know

  • @cesarramosh.9462
    @cesarramosh.9462 6 років тому

    Thanks a lot, this video is really good.

  • @dragonish97
    @dragonish97 4 роки тому +2

    Nice! thx bro

  • @giftmsowoya760
    @giftmsowoya760 2 роки тому

    Very helpful.

  • @marcohidalgo2662
    @marcohidalgo2662 7 років тому

    Very helpfull, thanks :)

  • @tarsilaguimaraes
    @tarsilaguimaraes 7 років тому +3

    That video does not help at all. Same problem from the comments below

  • @bouchraalg0215
    @bouchraalg0215 Рік тому

    Thank you

  • @RuhulAmin-th3zj
    @RuhulAmin-th3zj 3 роки тому

    thank you sir

  • @iancu2999
    @iancu2999 3 роки тому

    thanks man

  • @jc247100
    @jc247100 6 років тому

    didn't work

  • @dfaltin
    @dfaltin 6 років тому +1

    Does not work for me ... STATA is killing me, will use Eviews

    • @miguelcastro9153
      @miguelcastro9153 5 років тому

      i think that it is important to make a tab1 to all the variables we would like to "destring". Tab1 var1 var2 var3 avoid to do separeately tab var1, tab var2, etc. For "destring" ALL YOUR DATA should be a number (in a string format, obviously) because If you have in your variable any "text" for example "no data", Stata will not execute the order we want. That was my own experience.

    • @lmgpc
      @lmgpc 5 років тому

      I´m with R, Stata is shit for handle variables. I have to use it because my boss

  • @yewut
    @yewut 2 роки тому

    thx

  • @jacobocamargomedina8501
    @jacobocamargomedina8501 8 місяців тому

    Capo