Announcement

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

  • Stata (14) suddenly displaying an additional exponent value (e.g. 6.2e+26) when I tabulate a dummy variable

    If the subject line isn't clear, here's a picture of what I'm referring to:
    Click image for larger version

Name:	Stata 14.0 — 2016ANES.dta Stata 14.0, Today at 4.29.26 PM.png
Views:	1
Size:	18.0 KB
ID:	1401488

    Not really sure why this suddenly started happening; but it's also rearing itself in other variables as well. Anybody have any idea how to fix this? Thanks!

  • #2
    Welcome to Statalist, Zach.

    What happens when you do the following?
    Code:
    list if Male>1

    Comment


    • #3
      Thanks William!

      I wish I could attach a screen shot, but the output appears to go on forever heh. From what I can see, though, it lists mostly exponential values . Really stumped why this is happening--I don't recall tinkering with anything. Look forward to hearing back from you. Thanks for taking the time out of your day to help!

      Edit: I should add that 'recode Male (6.2e+26=.)' returns a '(Male: 0 changes made)'

      -Zach
      Last edited by Zach Goldberg; 11 Jul 2017, 16:46.

      Comment


      • #4
        What observation is it? Perhaps 4219, the last observation? In which case, are you reading your data from an Excel spreadsheet or something else that isn't a Stata dataset? It shows every sign of have had an extra row full of junk added to it. How many observations are you supposed to have, because you now have 4219? If you don't have good answers to these questions, you should go back to your original data, not just hammer on the bad observation replacing values with no real way of knowing if your replacement is correct. Just because Male>0 does not mean the original data was not Male=0.

        You don't want recode, you want replace, if you indeed know that that observation is male.
        Code:
        replace Male = 1 if Male>1
        Last edited by William Lisowski; 11 Jul 2017, 18:20. Reason: Fixed margarita-induced typographical errors: the sun is over the yardarm here, as the expression goes.

        Comment


        • #5
          It appears to be observation #12. At least for gender, the original data shows 4219 observations.

          are you reading your data from an Excel spreadsheet or something else that isn't a Stata dataset
          Nope..it's your standard Stata .dta file. Here is a screen shot from the data browser:
          Click image for larger version

Name:	Data Editor (Browse) — 2016ANES.dta Stata 14.0, Today at 8.38.29 PM.png
Views:	1
Size:	64.5 KB
ID:	1401517

          Comment


          • #6
            Then it certainly seems like the right thing to do is to go back to the original data.

            Comment


            • #7
              I think you may be dealing with 'precision' issues. The odd values seem to be just zero. Perhaps, instead of int or byte, you have double.
              Best regards,

              Marcos

              Comment


              • #8
                Hey Marcos,

                I can try changing it to int or byte. How do I do that though?

                Thanks!

                -Zach

                Comment


                • #9
                  Originally posted by William Lisowski View Post
                  Then it certainly seems like the right thing to do is to go back to the original data.
                  That would mean I'd have to recode/regenerate dozens of variables. Is that really the only 'fix' here?

                  Comment


                  • #10
                    I take it you did the recoding by hand, so you don't have a saved do-file to reapply to the data?

                    I guess the alternative would be to locate the original of the damaged observation in your original data, keep that observation, creating a one-observation dataset that you save in a temporary file, and append that file to the current dataset, then open it in the Data Editor window. Suppose each record has an ID, and the damaged observation has ID==42, then the command edit if ID==42 will open the Data Editor displaying just those two observations. Then get to work copying and pasting.

                    Or, if you're using a Mac with a Time Machine backup, try recovering an older copy of the file.

                    Comment


                    • #11
                      Actually have most of the coding saved in a do-file (thus I went ahead and re-executed). Still would like to figure out 'why' this happens, as it's not the first time.

                      Comment


                      • #12
                        Originally posted by Zach Goldberg View Post
                        Actually have most of the coding saved in a do-file (thus I went ahead and re-executed). Still would like to figure out 'why' this happens, as it's not the first time.
                        It shouldn't happen. Either the input data is seriously wrong, or you are doing something wrong, or... you might have a deeper issue, like a memory corruption error. Quite uncommon, but might happen. Might be worth a shot as a last resource to try on a different PC. Also, add assertions like "assert inlist(x, 0, 1)"

                        Comment


                        • #13
                          Hey Marcos,

                          I can try changing it to int or byte. How do I do that though?

                          Thanks!

                          -Zach
                          You may use - recast - with the option "force".

                          See the toy example below:


                          Code:
                          . set obs 5
                          number of observations (_N) was 0, now 5
                          
                          . input double oddnumber
                          
                                oddnumber
                            1. 0.0000000000000000000000000000000000000000000000000000000000043
                            2. 0.0000000000000000000000000000000000000000000000000000000000000023
                            3. 0.00000000000000000000000000000000000000000000000000000000000000000000000000056
                            4. 1
                            5. 0
                          
                          . list
                          
                               +-----------+
                               | oddnumber |
                               |-----------|
                            1. | 4.300e-60 |
                            2. | 2.300e-63 |
                            3. | 5.600e-76 |
                            4. |         1 |
                            5. |         0 |
                               +-----------+
                          
                          . recast int oddnumber, force
                          oddnumber:  3 values changed
                          
                          . list
                          
                               +----------+
                               | oddnum~r |
                               |----------|
                            1. |        0 |
                            2. |        0 |
                            3. |        0 |
                            4. |        1 |
                            5. |        0 |
                               +----------+
                          Hopefully that helps!
                          Last edited by Marcos Almeida; 12 Jul 2017, 05:23.
                          Best regards,

                          Marcos

                          Comment

                          Working...
                          X