Announcement

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

  • why stata did not read my imported excel? all the numbers in my excel are showed in red. stata shows no observation

    Click image for larger version

Name:	QQ20200215-183524@2x.png
Views:	1
Size:	14.4 KB
ID:	1536737
    i imput my excel, stata shows this

  • #2
    That does not tell you that Stata did not read your imported Excel. It tells you that, having read the Excel worksheet, no observations qualified to be included in the regress command.

    My guess is that one or both of your variables infrate and uemprate were imported as string variables rather than numeric. Try
    Code:
    describe infrate uemprate
    and see what that tells you.

    Comment


    • #3
      Also list infrate and uemprate.

      Comment


      • #4
        The fact that your numbers are showing up in red when you look at the data means that they have been imported as strings.

        Remember that Excel imposes no discipline on the contents of cells in spreadsheets. If the variables you think of as numeric sometimes appear in your Excel file as "N/A" or ">15" or "2-3" or contain anything other than digits 0 through 9 and a single decimal point, and perhaps a leading minus sign, then they will be understood as strings by Stata.

        So you need to -destring- these variables. But to do that, you must first clean up the non-numeric content that caused Stata to import them as strings in the first place.

        Code:
        list infrate if missing(real(infrate))
        list uemprate if missing(real(uemprate))
        will show you all the values of infrate and uemprate that contain text that cannot be read as a number. Fix those observations. Then run -destring infrate uemprate, replace- and you will be able to use these variables for analysis.

        Comment


        • #5
          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

          Working...
          X