proc sql;
create table e as select * from a, d order by n;quit;
data e_2;
set e;
if prom1=prom_1 or prom1=prom_2 or prom1=prom_3 or prom1=prom_4 or prom1=prom_5 then flag1=1;
if prom2=prom_1 or prom2=prom_2 or prom2=prom_3 or prom2=prom_4 or prom2=prom_5 then flag2=1;
if flag1 ne 1 or flag2 ne 1 then delete;
promm=compress(prom1||'-'||prom2);
run;
proc transpose data=e_2 out=f(drop=_name_ n);
var promm;
by n Prod Prom_1 Prom_2 Prom_3 Prom_4 Prom_5 ;
run;作者: shiyiming 时间: 2007-3-26 15:52 标题: 谢谢 谢谢dragonin的大力帮助,我试试看:)作者: shiyiming 时间: 2007-3-26 23:14 标题: 谢谢 第一个问题看来最核心的还是tranwrd、compress、compbl等字符串函数的应用:)
关于第二个问题,我看明白了,你把 a, d 表连起来生成e表,然后在e表上操作就比较容易了。但是有一个问题:e表的纪录数=a表记录数*d表记录数;如果a表有10万条记录,d表也有几万条记录,那这样e表记录数狂多,是不是效率不高啊?看看是否还有其他解决办法。作者: shiyiming 时间: 2007-3-26 23:51 标题: 关于sashelp.vcolumn和sashelp.vtable 刚查看了一下关于sashelp.vcolumn,原来是meta tables(数据的数据),里面信息还不少。
proc sql;
select max(varnum) into : no from sashelp.vcolumn where memname='B_2';quit;
另外,建议用proc sql来使用 Dictionary 表。如果将其用在Data步里,会慢很多。作者: shiyiming 时间: 2007-3-28 17:21 标题: re SAS does not maintain DICTIONARY table information between queries. Eachquery of a DICTIONARY table launches a new discovery process. Therefore, if youare querying the same DICTIONARY table several times in a row, then you can geteven better performance by creating a temporary SAS data set (by using the DATA step SET statement or PROC SQL CREATE TABLE AS statement) that includes the information that you want and running your query against that data set.
271 proc sql stimer ;
NOTE: SQL Statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
272 select * from dictionary.tables;
NOTE: SQL Statement used (Total process time):
real time 3.25 seconds
cpu time 0.78 seconds
272! quit;
NOTE: PROCEDURE SQL used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
273 proc sql stimer ;
NOTE: SQL Statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
274 select * from sashelp.vtable;
NOTE: SQL Statement used (Total process time):
real time 3.11 seconds
cpu time 0.53 seconds
274! quit;
NOTE: PROCEDURE SQL used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds作者: shiyiming 时间: 2007-4-4 15:19 标题: 为什么还要标题 [code:a139f]
data AAA ;
infile datalines truncover;
input Prod Prom_1 Prom_2 Prom_3 Prom_4 Prom5 ;
datalines;
1001 12 23 34 45
1001 12 26 34 56
1002 23 24
1002 23 25 35
1002 23 45
;
run;
DATA FINAL (KEEP=Prom_1 Prom_2 Prom_3 Prom_4 Prom5 Invalid);
SET AAA;
length invalid $ 100;
Invalid='';
array PArr Prom_1 Prom_2 Prom_3 Prom_4 Prom5;
do i=1 to &vnum;
count=0;
set CCC point=i;
do over PArr;
count=count+(PArr=prom1)+(PArr=prom2);
end;
if count>=2 then Invalid=compress(trim(invalid)||'||'||prom1||'-'||prom2);
end;
if substr(invalid,1,1)='|' then invalid=substr(invalid,3);
run;[/code:a139f]
楼上的签名档是在自谦吗?吼吼吼吼吼. 看过你三个贴子,每贴必用TRANSPOSE,狂汗中........................
一RUN完就发现楼主的举例中第一条就少了一组INVALID的信息.呵呵呵.作者: shiyiming 时间: 2007-4-12 23:10 标题: 谢谢 通过dragonin和ahuige两位大虾的程序,让我又学到了很多东西,非常感谢!不知道两位都是从事什么行业的呢?有机会做一些SAS编程应用方面的交流。