Stata Bysort. Reg depvar indvar example. Then for observations with common var1 stata will sort them according to var2.
Bysort runs a command seperately for each value of a variable. Description most stata commands allow the byprefix which repeats the command for each group of observations for which the values of the variables in varlist are the same. Stata has two system variables that always exist as long as data is loaded n and n.
By requires that the data is sorted by the variable in question and cannot be abbreviated bysort sorts the data for you and may be abbreviated bys.
To illustrate let s use stocks dta. By requires that the data is sorted by the variable in question and cannot be abbreviated bysort sorts the data for you and may be abbreviated bys. Reg depvar indvar example. Reg hhsize age r.
