今回はORDER BYについて解説します。
/* order by_1 */
data data1;
Id1=1111; Id2=1111; Id3=1111;
output;
Id1=2222; Id2=2222; Id3=2222;
output;
Id1=3333; Id2=3333; Id3=3333;
output;
run;
proc sql;
create table data2 AS
select * from data1
order by Id1;
quit;
![](https://how-to-business.com/wp-content/uploads/2022/02/order-by_1_1.png)
![](https://how-to-business.com/wp-content/uploads/2022/02/order-by_1_2.png)
- order byで並び替えて出力できる。
/* order by_2 */
data data1;
Id1=1111; Id2=1111; Id3=1111;
output;
Id1=3333; Id2=3333; Id3=3333;
output;
Id1=2222; Id2=2222; Id3=2222;
output;
run;
proc sql;
create table data2 AS
select * from data1
order by Id1;
quit;
![](https://how-to-business.com/wp-content/uploads/2022/02/order-by_2_1.png)
![](https://how-to-business.com/wp-content/uploads/2022/02/order-by_2_2.png)
- order byで並び替えて出力できる。