Dear all, How can I sort for each column/variable so that the values are in ascending order for each column/variable?
I have the following code to do this, but wonder if there exists a more concise way.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(var1 var2 var3) -.000565588 .003170494 .0004866 .00274415 .001754911 -.005638469 -.007524003 .008604493 .000423284 -.003661071 -.00127114 -.000131669 .003904666 -.000133898 -.005763379 .001541395 -.003228544 -.001410524 .0038835 -.001180972 .004857452 -.000484614 -.007589492 -.000792214 -.008681948 .00113195 -.005468268 -.006704849 -.002468719 .000455252 end
Code:
gen t0 = _n reshape long var, i(t0) j(i) bys i (var): gen t1 = _n drop t0 reshape wide var, i(t1) j(i) drop t1
Comment