tostring Time_period, gen(time) u force bys time:asdoc sum Lerner_w
Reply To: bysort prefix with date format in asdoc messes up the date order
Since Stata treats date variables as numeric, asdoc reports the numeric variable without formating it as a Stata date. I think it can be fixed sometime in future, but at the moment, the trick is to convert the date variable first to a string and then use it with asdoc, like this