楼主: l6397
2073 4

[SAS] [求助]求教:排序的问题 [推广有奖]

  • 0关注
  • 0粉丝

博士生

42%

还不是VIP/贵宾

-

威望
0 级
论坛币
120 个
通用积分
16.6418
学术水平
1 点
热心指数
6 点
信用等级
0 点
经验
3788 点
帖子
235
精华
0
在线时间
178 小时
注册时间
2007-3-28
最后登录
2023-5-13

楼主
l6397 发表于 2008-1-22 01:06:00 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
<p>求教:排序的问题</p><p>&nbsp;&nbsp;&nbsp;&nbsp; 有6种商品(A,B,C,D,E,F),下面分别是它们2天的价格:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </p><p><table cellspacing="0" cellpadding="0" width="257" border="0" style="WIDTH: 196pt; BORDER-COLLAPSE: collapse;"><colgroup><col width="53" style="WIDTH: 40pt; mso-width-source: userset; mso-width-alt: 1696;"></col><col span="6" width="34" style="WIDTH: 26pt; mso-width-source: userset; mso-width-alt: 1088;"></col></colgroup><tbody><tr height="16" style="HEIGHT: 12pt;"><td class="xl24" width="53" height="16" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext 0.5pt solid; BORDER-LEFT: windowtext 0.5pt solid; WIDTH: 40pt; BORDER-BOTTOM: windowtext 0.5pt solid; HEIGHT: 12pt; BACKGROUND-COLOR: transparent;"><p align="center"><font face="宋体" size="2">序号</font></p></td><td class="xl24" width="34" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext 0.5pt solid; BORDER-LEFT: windowtext; WIDTH: 26pt; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><p align="center"><font face="宋体" size="2">A</font></p></td><td class="xl24" width="34" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext 0.5pt solid; BORDER-LEFT: windowtext; WIDTH: 26pt; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><p align="center"><font face="宋体" size="2">B</font></p></td><td class="xl24" width="34" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext 0.5pt solid; BORDER-LEFT: windowtext; WIDTH: 26pt; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><p align="center"><font face="宋体" size="2">C</font></p></td><td class="xl24" width="34" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext 0.5pt solid; BORDER-LEFT: windowtext; WIDTH: 26pt; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><p align="center"><font face="宋体" size="2">D</font></p></td><td class="xl24" width="34" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext 0.5pt solid; BORDER-LEFT: windowtext; WIDTH: 26pt; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><p align="center"><font face="宋体" size="2">E</font></p></td><td class="xl24" width="34" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext 0.5pt solid; BORDER-LEFT: windowtext; WIDTH: 26pt; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><p align="center"><font face="宋体" size="2">F</font></p></td></tr><tr height="16" style="HEIGHT: 12pt;"><td class="xl24" height="16" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext 0.5pt solid; BORDER-BOTTOM: windowtext 0.5pt solid; HEIGHT: 12pt; BACKGROUND-COLOR: transparent;"><p align="center"><font face="宋体" size="2">1</font></p></td><td class="xl25" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><p align="center"><font face="宋体" size="2">1.9 </font></p></td><td class="xl25" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><p align="center"><font face="宋体" size="2">1.2 </font></p></td><td class="xl25" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><p align="center"><font face="宋体" size="2">2.0 </font></p></td><td class="xl25" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><p align="center"><font face="宋体" size="2">3.1 </font></p></td><td class="xl25" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><p align="center"><font face="宋体" size="2">1.0 </font></p></td><td class="xl25" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><p align="center"><font face="宋体" size="2">1.8 </font></p></td></tr><tr height="16" style="HEIGHT: 12pt;"><td class="xl24" height="16" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext 0.5pt solid; BORDER-BOTTOM: windowtext 0.5pt solid; HEIGHT: 12pt; BACKGROUND-COLOR: transparent;"><p align="center"><font face="宋体" size="2">2</font></p></td><td class="xl25" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><p align="center"><font face="宋体" size="2">2.5 </font></p></td><td class="xl25" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><p align="center"><font face="宋体" size="2">1.5 </font></p></td><td class="xl25" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><p align="center"><font face="宋体" size="2">1.0 </font></p></td><td class="xl25" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><p align="center"><font face="宋体" size="2">2.3 </font></p></td><td class="xl25" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><p align="center"><font face="宋体" size="2">1.6 </font></p></td><td class="xl25" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><p align="center"><font face="宋体" size="2">1.4 </font></p></td></tr></tbody></table>
        </p><p>如何编程,制成下表:</p><p><table cellspacing="0" cellpadding="0" width="257" border="0" style="WIDTH: 196pt; BORDER-COLLAPSE: collapse;"><colgroup><col width="53" style="WIDTH: 40pt; mso-width-source: userset; mso-width-alt: 1696;"></col><col span="6" width="34" style="WIDTH: 26pt; mso-width-source: userset; mso-width-alt: 1088;"></col></colgroup><tbody><tr height="16" style="HEIGHT: 12pt;"><td class="xl24" width="53" height="16" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext 0.5pt solid; BORDER-LEFT: windowtext 0.5pt solid; WIDTH: 40pt; BORDER-BOTTOM: windowtext 0.5pt solid; HEIGHT: 12pt; BACKGROUND-COLOR: transparent;"><p align="center"><font face="宋体" size="2">序号</font></p></td><td class="xl24" width="34" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext 0.5pt solid; BORDER-LEFT: windowtext; WIDTH: 26pt; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><p align="center"><font face="宋体" size="2">X1</font></p></td><td class="xl24" width="34" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext 0.5pt solid; BORDER-LEFT: windowtext; WIDTH: 26pt; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><p align="center"><font face="宋体" size="2">X2</font></p></td><td class="xl24" width="34" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext 0.5pt solid; BORDER-LEFT: windowtext; WIDTH: 26pt; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><p align="center"><font face="宋体" size="2">X3</font></p></td><td class="xl24" width="34" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext 0.5pt solid; BORDER-LEFT: windowtext; WIDTH: 26pt; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><p align="center"><font face="宋体" size="2">X4</font></p></td><td class="xl24" width="34" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext 0.5pt solid; BORDER-LEFT: windowtext; WIDTH: 26pt; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><p align="center"><font face="宋体" size="2">X5</font></p></td><td class="xl24" width="34" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext 0.5pt solid; BORDER-LEFT: windowtext; WIDTH: 26pt; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><p align="center"><font face="宋体" size="2">X6</font></p></td></tr><tr height="16" style="HEIGHT: 12pt;"><td class="xl24" height="16" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext 0.5pt solid; BORDER-BOTTOM: windowtext 0.5pt solid; HEIGHT: 12pt; BACKGROUND-COLOR: transparent;"><p align="center"><font face="宋体" size="2">1</font></p></td><td class="xl25" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><p align="center"><font face="宋体" size="2">D&nbsp;</font></p></td><td class="xl25" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><p align="center"><font face="宋体" size="2">C&nbsp;</font></p></td><td class="xl25" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><p align="center"><font face="宋体" size="2">A&nbsp;</font></p></td><td class="xl25" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><p align="center"><font face="宋体" size="2">F&nbsp;</font></p></td><td class="xl25" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><p align="center"><font face="宋体" size="2">B&nbsp;</font></p></td><td class="xl25" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><p align="center"><font face="宋体" size="2">E&nbsp;</font></p></td></tr><tr height="16" style="HEIGHT: 12pt;"><td class="xl24" height="16" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext 0.5pt solid; BORDER-BOTTOM: windowtext 0.5pt solid; HEIGHT: 12pt; BACKGROUND-COLOR: transparent;"><p align="center"><font face="宋体" size="2">2</font></p></td><td class="xl25" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><p align="center"><font face="宋体" size="2">A&nbsp;</font></p></td><td class="xl25" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><p align="center"><font face="宋体" size="2">D&nbsp;</font></p></td><td class="xl25" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><p align="center"><font face="宋体" size="2">E&nbsp;</font></p></td><td class="xl25" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><p align="center"><font face="宋体" size="2">B</font></p></td><td class="xl25" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><p align="center"><font face="宋体" size="2">F&nbsp;</font></p></td><td class="xl25" style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent;"><p align="center"><font face="宋体" size="2">C&nbsp;</font></p></td></tr></tbody></table></p><p>&nbsp;&nbsp;变量X1,X2,X3,X4,X5,X6&nbsp;&nbsp;是降序排列&nbsp; </p><p>表示第1天,商品D价格最高,C第2。。。E最低。</p><p>到第2天,商品A价格最高,D第2。。。C最低。</p><p>再第3天。。。。。。。。</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;谢谢!!!!! </p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </p><p></p><p></p><p></p><p></p><p></p><p></p>
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:ABCD 降序排列 def CDE ABC 求助 求教

回帖推荐

yzhouwen 发表于4楼  查看完整内容

1. proc transpose, transfer data as:         _name_  x1 x2 ............           A     1.9  2.5           B     1.2  1.5           C   &nbs ...

nkwilling 发表于2楼  查看完整内容

data a;input id$ D1 D2;cards;A 1.9 2.5B 1.2 1.5C 2 1D 3.1 2.3E 1 1.6F 1.8 1.4;RUN;proc sort data=a(keep=id d1 rename=(id=id1)) out=b1; by descending d1 ;run;proc sort data=a(keep=id d2 rename=(id=id2)) out=b2; by descending d2;run;data out; merge b1 b2;run;如果每天都有数据,需要把上面所有的程序做成宏程序.

本帖被以下文库推荐

沙发
nkwilling 发表于 2008-1-23 12:18:00
<p>data a;<br/>input id$ D1 D2;<br/>cards;<br/>A 1.9&nbsp;2.5<br/>B 1.2&nbsp;1.5<br/>C 2&nbsp;1<br/>D 3.1&nbsp;2.3<br/>E 1&nbsp;1.6<br/>F 1.8&nbsp;1.4<br/>;<br/>RUN;</p><p>proc sort data=a(keep=id d1 rename=(id=id1)) out=b1;<br/>&nbsp;by descending d1 ;<br/>run;</p><p>proc sort data=a(keep=id d2 rename=(id=id2)) out=b2;<br/>&nbsp;by descending d2;<br/>run;</p><p>data out;<br/>&nbsp;merge b1 b2;<br/>run;</p><p>如果每天都有数据,需要把上面所有的程序做成宏程序.</p><p></p>
已有 1 人评分经验 论坛币 收起 理由
bakoll + 3 + 10 精彩帖子

总评分: 经验 + 3  论坛币 + 10   查看全部评分

藤椅
l6397 发表于 2008-1-23 16:21:00
<p>首先,感谢版主!您亲自教导,倍受感动。</p><p>我还有几个问题,请教老师:</p><p>1、我的数据已经以 1楼上表的形式存入SAS数据集中,怎样一行一行地(每天的6种商品)读取再</p><p>&nbsp;&nbsp; 按降序排列。</p><p>2、输出方式按 1楼下表的形式输出,只需要一行一行地输出商品名称的降序排列(即 DCAFBE),</p><p>&nbsp;&nbsp; 不需要价格。</p><p>&nbsp;&nbsp;谢谢!!!!!</p>

板凳
yzhouwen 发表于 2008-1-24 03:17:00
<p>1. proc transpose, transfer data as:</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _name_&nbsp; x1 x2 ............</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; A&nbsp;&nbsp;&nbsp;&nbsp; 1.9&nbsp; 2.5</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; B&nbsp;&nbsp;&nbsp;&nbsp; 1.2&nbsp; 1.5</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; C&nbsp;&nbsp;&nbsp;&nbsp; 2.0&nbsp; 1.0</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; D&nbsp;&nbsp;&nbsp;&nbsp; 3.0&nbsp; 2.3 </p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; E&nbsp;&nbsp;&nbsp;&nbsp; 1.0&nbsp; 1.6</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; F&nbsp;&nbsp;&nbsp;&nbsp; 1.8&nbsp; 1.4</p><p>2. use macro, every time choose _Name_, X&amp;i as a new dataset, do sort. </p><p>3.transfer back.</p>
已有 1 人评分经验 论坛币 收起 理由
bakoll + 3 + 10 精彩帖子

总评分: 经验 + 3  论坛币 + 10   查看全部评分

报纸
l6397 发表于 2008-1-24 18:24:00
<p>Thank you very much !!!</p><p>&nbsp;&nbsp;&nbsp; 不知各位老师,还有没有其他方法? 谢谢!!</p>

您需要登录后才可以回帖 登录 | 我要注册

客服
GMT+8, 2026-12-1 11:09