Announcement

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

  • Display format in stata 14

    Dear colleagues,
    My dataset contains a numeric variable type but stored as float and I would like to change this variable type to double.

    For example because the figure 6,658,746.00 is stored as float it is displayed as 6.6587. I cannot see the remaining figures and cannot figure out how to widen the column to view all the numbers or to change the variable type from float to double..
    I followed the display format instructions but this did not work. Grateful if some could please help.
    thank you in advance.


  • #2
    Please review the Statalist FAQ linked to from the top of the page, as well as from the Advice on Posting link on the page you used to create your post, looking especially at sections 9-12 on how to best pose your question. It would be particularly helpful to post a sample of your data using the dataex command, as describe in section 12 of the FAQ. To install dataex, type ssc install dataex and when that is complete type help dataex to read the simple instructions for using it. Using dataex will enable those who want to help you to quickly and easily create a 100% faithful replica of your situation to test their ideas and code on.

    With that said, the example below suggests to me that your value is actually stored as 6.6587 and not as 6658746, since the latter displays correctly.
    Code:
    . clear
    
    . input float x
    
                 x
      1. 6658746
      2. end
    
    . list
    
         +---------+
         |       x |
         |---------|
      1. | 6658746 |
         +---------+
    
    .

    Comment


    • #3
      William gives excellent advice. You can

      Code:
      recast double x
      but nothing in that will restore whatever detail may have been lost when your variable was created as float.

      The solution is likely to be a better display format. As you don't show us what formatting you tried, it's hard to comment until you show us a good data example.

      Comment


      • #4
        Thank you very much William and Nick for the advice, highly appreciated. will re-work the data as suggested.

        Comment


        • #5
          thanks Nick, recast worked and now the variable is stored as double. However, I still have an issue that the figure is displayed in the data editor as 82.24342. but when I point the cusor to this cell the figure is fully displayed on the tool bar on top a 82.2434248291. I want the figure to be displayed in full in both the data editor and tool bar with commas 822,434,248,291.
          I have repeatedly tried to format this numeric variable but I receive an error message: this format is not for numeric variables, grateful if you can please help.
          thanks

          Comment


          • #6
            storage type is double
            display format %9.0g

            Comment


            • #7
              From what you say I can only guess that the data are mangled. If you know that a value should be 822,434,248,291 then that display format could not possibly show 82.24342. At some point the data were divided by 10 billion.

              Comment


              • #8
                Thanks Nick you are right. What us is played in the data editor is 82.2434. In the tool bar I see the full figure 82.2434247.

                in the data editor I want the full figure displayed 822,434,247. Thank you

                Comment


                • #9
                  What I have told you in post #2 and Nick has told you in post #7 is that the number is displayed in the toll bar as it is stored in Stata.

                  If in post #8 you want 82.243247 displayed as 822,424,247 you will have to multiply it by 10000000, in post #5 if you want 82.2434248291 displayed as 822,434,248,291 you will have to multiply it by 10000000000.

                  Comment


                  • #10
                    Hello Nick, does the additional information I provide help? Thanks again Liz

                    Comment


                    • #11
                      Thanks William. I fully understand. Why is the figure stored in STATA not fully displayed in the data editor? This is my problem. Formatting did not work. Thanks again

                      Comment


                      • #12
                        Liz: We are going round in circles here.

                        William Lisowski and I and anybody else watching know absolutely nothing about how your data were imported or what grounds you have for saying that the data should be as you think.

                        We trust that you know what the data should be, but Stata thinks your values are what it says they are. Note that no format change will multiply up or down. So, you can

                        1. go back to how the data were imported and check out what happened.

                        2. accept the data as they are.

                        3. multiply by 100 billion or 10 million or 1 million or whatever the factor should be (your posts in #1 and #5 and #8 all give different stories if I understand you correctly).

                        4. ask someone who should know about these data what is happening (not us).

                        I doubt that we can otherwise add anything to what has been said already.

                        Comment


                        • #13
                          Thanks William. Indeed we are going round in circles. The issue is simple: how to widen the column width and allow for a full display of all figures in the data editor, as stored in STATA and not only in the tool bar. I cannot find this info in Stata. But it is ok do not bother.

                          Comment


                          • #14
                            I am not William, although we rarely disagree.

                            The issue is that you don't understand why your data are not displaying as you want.

                            Stata has no idea of column width. It's not as if you were back in grade or primary school (local terminology is likely to differ) and writing numbers on squared paper one digit at a time. It does have a idea of display format but as already said no change of display format will supply the large factors you need to get the data to show as you want. You can't find this information because your question isn't a Stata question. It's a question about your data and Stata can have no idea of what they should be independently of what you tell it.

                            It's on all fours with having a proportion and wanting to see a percent, or vice versa: there the knowledge is all in the user's head as needing a factor of 100 one way or the other.

                            Comment


                            • #15
                              Very nice tone and helpful indeed.
                              thanks😂

                              Comment

                              Working...
                              X