markdown SAS中的排序功能

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown SAS中的排序功能相关的知识,希望对你有一定的参考价值。

# Sort function in SAS


# By

Basic sort function. Uses **by**. 

```sas
proc sort data=work.test;
by Salary;
run;
```

# Class 

Alternative for by is class. We can use either by or class.

```sas
proc sort data=work.test;
class Salary;
run;
```


The default is **ascending/alphabatical** value. For reverse order use **descending**

Sort in **descending** order

```sas
proc sort data=work.test;
by descending Salary;
run;
```

Sort in **ascending** order

```sas
proc sort data=work.test;
by Salary;
run;
```

Sort in **alphabatical** order

```sas
proc sort data=work.test;
by name;
run;
```

Sort in **reverse alphabatical** order

```sas
proc sort data=work.test;
by descending name;
run;
```

Sorting by **multiple variables**. Simply **add two variables** instead of one. **Sequence** matters.

```sas
proc sort data=work.test;
by post salary;
run;
```

Sort post then descending salary

```sas 
proc sort data=work.test;
by post descending salary;
run;
```

Sort descending post and then salary

```sas 
proc sort data=work.test;
by descending post salary;
run;
```

Sort descending post then descending salary

```sas 
proc sort data=work.test;
by descending post descending salary;
run;
```

以上是关于markdown SAS中的排序功能的主要内容,如果未能解决你的问题,请参考以下文章

如何使用SAS中的数据步骤对数据进行排序

markdown SAS的全球声明

markdown 在SAS中计算平均值

markdown SAS规则

markdown 在SAS中创建/导入数据

markdown 在SAS中打印