SAS中文论坛

标题: 求教SAS表格网页显示?急急急!!!!!!! [打印本页]

作者: shiyiming    时间: 2010-11-8 10:03
标题: 求教SAS表格网页显示?急急急!!!!!!!
如何将一张这样的SAS表格:
  cur_cell          kind         des_rate  seq
1  一炼钢      产生      0.02         1
2  ********           热轧归户   0.07        1
3  ********           冷轧归户   0.07        1
4  一炼钢      产生      0.05         2
5  *********         热轧归户  0.03        2
6  *********        冷轧归户  0.06        2
7  电炉        产生      0.05        3

上面的********表示没东西,空的 由于不好显示所以用星号代替。


在网页上这样显示:
一炼钢 产生 2% 冷轧归户 7% 热轧归户 7%
二炼钢 产生 5% 冷轧归户 3% 热轧归户 6%
电炉 产生 5%
横着显示成这样:一炼钢 产生 2% 冷轧归户 7% 热轧归户 7%  二炼钢 产生 5% 冷轧归户 3% 热轧归户 6%  电炉 产生 5%我可以显示 但是怎么让它按一炼钢二炼钢换行呢? 高手指教!!!!!!!!!!
作者: shiyiming    时间: 2010-11-16 01:43
标题: Re: 求教SAS表格网页显示?急急急!!!!!!!
Assume the dataset name is 'yourds';
Assume that the '*' meant blank in your data;
1. use Macro.


%macro tryit;

proc sql noprint;
select distinct kind into: allkind separated by ' '
from yourds;
%let nk=&sqlobs.;
quit;

data result;
set yourds;
retain lag '';
drop lag;
if not missing(cur_cell) then lag=cur_cell;
else cur_cell=lag;
run;

data result2;
set result;
by cur_cell notsorted;
array kds(&nk)  $;
array rts(&nk);
drop i;
retain kds: '' rts: 0;
if first.cur_cell then do i=1 to &nk.;
kds(i)='';
rts(i)=.;
end;
select(kind);
%do j=1 %to &nk;
%let kd=%scan(&allkind,&j);
when("&kd.") do;
kds&j.=kind;
rts&j.=des_rate;
end;
%end;
otherwise;
end;
if last.cur_cell then output;

run;

ods listing close;
ods html body="c:\projects\test\test.html";
proc print data=result2 noobs;
var cur_cell %do i=1 %to &nk; kds&i rts&i %end;;
run;
ods html close;

%mend;

%tryit;
*you may want to delete the head line from the HTML file.;




欢迎光临 SAS中文论坛 (https://mysas.net/forum/) Powered by Discuz! X3.2