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

แชร์
ฝัง
  • เผยแพร่เมื่อ 26 ก.ย. 2016
  • This video demonstrates how to convert a string variable to a numeric variable in Stata using the destring command.
    www.stata.com
    Copyright 2011-2019 StataCorp LLC. All rights reserved.

ความคิดเห็น • 54

  • @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 4 ปีที่แล้ว +2

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

    • @letuananh7205
      @letuananh7205 4 ปีที่แล้ว +2

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

  • @shashavengesayi6055
    @shashavengesayi6055 ปีที่แล้ว +1

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

  • @nextgengems
    @nextgengems 5 ปีที่แล้ว

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

  • @dim7918
    @dim7918 2 ปีที่แล้ว

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

  • @marceloemanoel16
    @marceloemanoel16 4 ปีที่แล้ว

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

  • @cesarramosh.9462
    @cesarramosh.9462 5 ปีที่แล้ว

    Thanks a lot, this video is really good.

  • @africansinportugal9046
    @africansinportugal9046 2 ปีที่แล้ว

    Thank you! This was helpful!

  • @jeanmarcelduarte5830
    @jeanmarcelduarte5830 3 ปีที่แล้ว

    Solved my problem, thank you very much!

  • @marcohidalgo2662
    @marcohidalgo2662 6 ปีที่แล้ว

    Very helpfull, thanks :)

  • @Non-disjunction
    @Non-disjunction 4 ปีที่แล้ว +6

    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 th-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 ปีที่แล้ว

      Thanks mate

  • @Emilytan5365
    @Emilytan5365 7 ปีที่แล้ว +23

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

    • @MrRobertLake
      @MrRobertLake 4 ปีที่แล้ว

      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 4 ปีที่แล้ว +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 ปีที่แล้ว

      Use the 'force' option or use encode

    • @wuodtitochannel1678
      @wuodtitochannel1678 2 ปีที่แล้ว +2

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

  • @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

  • @dragonish97
    @dragonish97 3 ปีที่แล้ว +2

    Nice! thx bro

  • @jabulanimathebula1472
    @jabulanimathebula1472 3 ปีที่แล้ว

    How do I convert categorical variable to continuous variable?

  • @giftmsowoya760
    @giftmsowoya760 ปีที่แล้ว

    Very helpful.

  • @shafiqullahyousafzai15
    @shafiqullahyousafzai15 3 ปีที่แล้ว

    Thanks from Afghanistan

  • @iancu2999
    @iancu2999 2 ปีที่แล้ว

    thanks man

  • @RuhulAmin-th3zj
    @RuhulAmin-th3zj 3 ปีที่แล้ว

    thank you sir

  • @bouchraalg0215
    @bouchraalg0215 ปีที่แล้ว

    Thank you

  • @gabri99grisel
    @gabri99grisel 7 ปีที่แล้ว +21

    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 5 ปีที่แล้ว

      @@ThiriWinHtike wow cool, thanks. you saved me

    • @yusufmemic
      @yusufmemic 5 ปีที่แล้ว

      deleting commas have worked, thanks :)

  • @yewut
    @yewut 2 ปีที่แล้ว

    thx

  • @jacobocamargomedina8501
    @jacobocamargomedina8501 หลายเดือนก่อน

    Capo

  • @tarsilaguimaraes
    @tarsilaguimaraes 6 ปีที่แล้ว +3

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

  • @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 4 ปีที่แล้ว

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