If you are looking for software to use, go to Huajun Software Park! software release
Location: front pageTutorial strategyTutorialComputer software tutorials How does Stata...

How to use Stata - How to sort data using Stata

Author: monster Date: 2020-12-28

STATA
STATA-17.0 official version

science tools Storage: 856.71MB Time: 2022-04-18

Software introduction: Stata official version is a very excellent practical science statistics software. Stata official version is powerful, efficient and professional, and provides data analysis...

Download now

Recently, many friends have said that they still don’t know how to use Stata to sort data? The editor below will share with you the operation method of using Stata to sort data. Friends in need should quickly read this article.

Here we take the database that comes with Stata as an example. Enter the command [sysuse auto, clear] to import Stata’s own data set 1978 Automobile Data.

How to sort data in Stata?

Next, we sort the variable Price in ascending order. Enter the command [sort price]. The following picture is a comparison before and after sorting.

How to sort data in Stata?
How to sort data in Stata?

If you want to sort in descending order, enter the command directly. The following figure is a comparison before and after the arrangement.

How to sort data in Stata?

If you need to sort multiple variables in ascending order at the same time, list the variables directly after sort. For example, enter the command [sort weight turn length] to sort these three variables, the effect is as follows.

How to sort data in Stata?
How to sort data in Stata?

Similarly, to sort multiple variables in descending order, directly enter the command [gsort -weight turn length] to sort these three variables. The effect is as follows.

How to sort data in Stata?

The above is the method shared by the editor to sort data using Stata. Friends who don’t know how to do it can learn it.

Related articles