Announcement

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

  • Destring non numeric variables after importing from Excel

    Hi everyone,

    I am encountering quite a basic problem, however cannot seem to find the right solution. I imported an excel file containing numbers to stata and the variables are seen in format string. I've tried to destring them, however I get the error stating that the values re non numeric. I have also tried the encode function however the values are wrong. Could someone advise me how to proceed?

    Thank you in advance!

  • #2
    See e.g. https://www.statalist.org/forums/for...iable-problems for discussion.


    Code:
    tab foo if missing(real(foo))
    is a pattern to note, meaning you need to see which string values can't be converted to numeric.

    Comment


    • #3
      Also note that importing data from Excel sometimes leads to extra rows or columns being imported and causing problems, some of which you may be experiencing.

      When using import excel it's a good idea to use the cellrange() and firstrow() options when possible to ensure you get what you're expecting, with no bonuses added in. Or, after importing the worksheet, use Stata's Data Browser and confirm that the rightmost variables and bottommost observations of your data are as you expect them to be.

      Comment


      • #4
        Thank you both! I managed to get it right taking your advises into account!

        Comment

        Working...
        X