Announcement

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

  • Problems summarizing

    Hi,
    I am quite new to stata and am trying to run a basic OLS regression for a large number of variables. I realised at some point that two of my variables had non-numeric data and so I manually changed the data into numeric using the data-editor. I then tabulated the data to see if there are any non-numeric values in there and there are none for either. Everything seemed fine till I tried to summarize. Stata does not seem to be summarizing either of the two variables. Any suggestions about what went wrong and how I can deal with this? When I tried using these two variables in an OLS regression, stata refuses to run the regression stating error r2000 (no observations). Thank you in advance!

  • #2
    Well, you don't really tell us how you attempted to change the variables to numeric in the data editor, so it's hard to know what you did wrong. But, in any case, I wouldn't use the data editor for that. I would use the -destring- command.

    Comment


    • #3
      If you used the data editor to change the values from alpha characters to numeric characters, they will still be string variables - they will just be string variables containing strings that look like numbers: "1", "2", etc. If you want actual numbers, you will need to create a new variable which is of numeric type, not string type. Based on your description, it seems your original variables contain alpha characters ("Yes", "No", "Maybe", etc) and so you want to use -encode-

      encode oldvar, gen(newvar)

      If on the other hand, you have strings that look like numbers ("1", "2", "34.75", etc) they you want to follow Clyde's advice and use -destring- or -real-

      gen newvar=real(oldvar)

      Hope this helps,
      Jeph

      Comment

      Working...
      X