Reply To: asdoc: using two variables with bysort for summary statistics Attaullah Shah 4 years ago Perhaps you need to use the tabstat command for this. tabstat is more flexible than sum command. And even you can give a try to the table command.