Announcement

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

  • Using the fre command within dtable

    I was wondering if there is any way to use the fre command within the code below to obtain the frequency tables with their numeric values and labels. Unfortunately, the formal stata command only reports labels not the values.


    dtable , by(`group', tests totals) continuous(`numeric' , statistics( mean sd)) factor(`factor' ) nolistwise export("descriptive.xlsx", as(xlsx) sheet(Sheet1, replace) cell(A1) replace) nformat(%3.1f) sformat("(%s)" mean)

  • #2
    That would be surprising, What you do is just redefine the value labels before you call up dtable. numlabel makes that easy to do (reversibly).

    Code:
    . sysuse auto, clear
    (1978 automobile data)
    
    . tab foreign
    
     Car origin |      Freq.     Percent        Cum.
    ------------+-----------------------------------
       Domestic |         52       70.27       70.27
        Foreign |         22       29.73      100.00
    ------------+-----------------------------------
          Total |         74      100.00
    
    . numlabel origin, add
    
    . tab foreign
    
     Car origin |      Freq.     Percent        Cum.
    ------------+-----------------------------------
    0. Domestic |         52       70.27       70.27
     1. Foreign |         22       29.73      100.00
    ------------+-----------------------------------
          Total |         74      100.00
    
    . numlabel origin, remove
    
    . tab foreign
    
     Car origin |      Freq.     Percent        Cum.
    ------------+-----------------------------------
       Domestic |         52       70.27       70.27
        Foreign |         22       29.73      100.00
    ------------+-----------------------------------
          Total |         74      100.00

    Comment

    Working...
    X