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

แชร์
ฝัง
  • เผยแพร่เมื่อ 30 พ.ย. 2024

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

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

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

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

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

      Thanks mate

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

      Use the 'force' option or use encode

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

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

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

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

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

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

    Thanks from Afghanistan

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

    Thank you! This was helpful!

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

    Solved my problem, thank you very much!

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

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

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

    Nice! thx bro

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

    Very helpful.

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

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

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

    Thanks a lot, this video is really good.

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

    How do I convert categorical variable to continuous variable?

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

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

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

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

    Very helpfull, thanks :)

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

    Thank you

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

    thanks man

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

    thank you sir

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

    thx

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

    Capo

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

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

    didn't work