
sas中如何将列表里面的按一定的顺序排列
物品价格a1b2c0.5d1.5如果我要求这个列表要按价格从低到高的顺序排列代码怎么写?...
物品 价格a 1b 2c 0.5d 1.5如果我要求这个列表要按价格从低到高的顺序排列 代码怎么写?
展开
2个回答
展开全部
利用Sort过程或者SQL过程中的Order by就很容易做到,具体代码如下:
options nodate pageno=1 ls=64 ps=80;
/*Produce the Original Data*/
data raw_data;
length brand $ 1;
input brand $ price@@;
datalines;
a 1 b 2 c 0.5 d 1.5
;
run;
/*Method 1 - Sorted the data by Price Ascendingly Using Proc Sort*/
proc sort data=raw_data out=sort_data;
by price;
run;
/*Method 2 - Sorted the data by Price Ascendingly Using Proc SQL*/
proc sql;
create table sort_data2 as
select brand, price
from raw_data
order by price;
quit;
/*Listing the Sorted Data*/
proc print data=sort_data n="The Number of Observations is:";
id brand;
var price;
title "Listing Original Data Sorted by Price Ascendingly";
run;
options nodate pageno=1 ls=64 ps=80;
/*Produce the Original Data*/
data raw_data;
length brand $ 1;
input brand $ price@@;
datalines;
a 1 b 2 c 0.5 d 1.5
;
run;
/*Method 1 - Sorted the data by Price Ascendingly Using Proc Sort*/
proc sort data=raw_data out=sort_data;
by price;
run;
/*Method 2 - Sorted the data by Price Ascendingly Using Proc SQL*/
proc sql;
create table sort_data2 as
select brand, price
from raw_data
order by price;
quit;
/*Listing the Sorted Data*/
proc print data=sort_data n="The Number of Observations is:";
id brand;
var price;
title "Listing Original Data Sorted by Price Ascendingly";
run;
2013-04-10
展开全部
在菜单上有排序功能的。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询