I would like to calculate time series means in a panel data set as
easily as pmean()  and  wonder if there is a built in function or
easier way than my script below. I am computing stock market returns
for a portfolio where px=1 was set to select the included
cross-sectional identifiers, and note I also need to weight (by market
value in this case).

smpl --full
series retp= NA
## Loop over dates
loop foreach dx  38748 38776 38807
    smpl --full
    ## Set sample dates and selected ids
    smpl DATE= $dx --restrict
    smpl px=1 --restrict
    ##  Compute weighted average returns as wls intercept coefficient
    wls mktval_lag ret const  --quiet
    series retp=$coeff(0)
endloop

Second and third thing:  I imported the data from EXCEL and the dates
are numbers (1/1/1900=0), hence my loop over 38748 38776 38807 that
are month end days.  Is there a easy way to get all date ids to loop
over and format as dates.

Reply via email to