Search code examples
statadate-rangesummarystandard-deviationskew

Stata - summary detail specifics (skewness and Std Dev) by id and date range


I have a panel data set with an id, date, and multiple variables. I'm trying to get the skewness and std dev of "var1" listed by id for a certain date range. I know those items are in the summary detail for "var1", but can't seem to find a way to get it listed by id for my specified date range. Any help would be greatly appreciated!


Solution

  • Here is an example that may start you on your path.

    . webuse pig
    (Longitudinal analysis of pig weights)
    
    . xtset id week
           panel variable:  id (strongly balanced)
            time variable:  week, 1 to 9
                    delta:  1 unit
    
    . bysort id: egen sk = skew(weight) if inrange(week,3,8)
    (144 missing values generated)
    
    . list if id==1, clean
    
           id   week   weight         sk  
      1.    1      1       24          .  
      2.    1      2       32          .  
      3.    1      3       39   .0709604  
      4.    1      4     42.5   .0709604  
      5.    1      5       48   .0709604  
      6.    1      6     54.5   .0709604  
      7.    1      7       61   .0709604  
      8.    1      8       65   .0709604  
      9.    1      9       72          .