Announcement

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

  • Problem with summary statistics without "," or "."

    Good Morning everybody,
    I have a problem: importing data from an excel sheet to Stata will convert the variable to a string. To be clear: I use commas "," for thousands, and "." for decimals on excel. To convert string variables into numeric ones I use the following code
    Code:
    destring assets2010, replace ignore(",")
    After using this code all the numbers are without any ",", as you can see.
    Code:
    assets2010
    4387459
    1028048
    655685
    1011944
    432152
    507172
    1552966
    93974
    2252309
    983583
    1826432

    The problem is that when I run a simple regress or calculate some summary statistics as mean then I have numbers without "," or any kind of signs.
    Code:
    ----------------------------------------------------------------------------
      assets2010 | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
        roaa2018 |   627404.9    3283442     0.19   0.849     -5871967     7126776
           _cons |    5258159    3074135     1.71   0.090    -826901.9    1.13e+07
    ------------------------------------------------------------------------------
    PS. the regress is just an example.
    Is there a way to have commas displayed in the summary statics of the regress functions (for instance for the coefficients)?
    I have another question: as you can see below
    Code:
    assets2010
    392096
    338992
    603169
    7259209
    302621
    500435
    1066255
    550826
    2288256
    428394
    
    237235
    3.330e+08
    258911
    1352623
    1739526
    618400
    One of the numbers is with exponential formatting and for confidence interval, this kind of formatting is again displayed. Is there a way to make it with the same format as the others?
    I know it can be an outsider but I still need some time to get familiar with data analysis.
    Thanks a lot to everybody for helping me.
    Regards

  • #2
    Code:
    h cformat
    which will let you, e.g., "set cformat %9.2fc"

    Comment


    • #3
      If you run -format assets2010 %12.0fc-, the data will be displayed with commas separating 3-digit groups when you -list-, -display-, or -browse- the data.

      To get similar formatting in the regression output is harder because a) the coefficients are usually not integers, so room is needed for the decimal places, and b) the -set cformat- command does not allow formats with a total width greater than 9, which often means there isn't enough room for all of the result, the decimal places, and the commas. But when the results can accommodate all of that -set cformat %9.1fc-, run before the regression command, will do the job.

      Added: Crossed with #2.
      Last edited by Clyde Schechter; 12 Jul 2022, 10:15.

      Comment


      • #4
        Thanks a lot for the help. Wish you the best.
        Regards

        Comment

        Working...
        X