楼主: cinaiyimu
9160 11

[SAS] 求助SAS查找字符的函数 [推广有奖]

11楼
lovexialulu 发表于 2018-5-9 17:53:39
不能copy 东西出来,用截图吧
加个input把 log clean下
if input(scan(var,j,','),best.)=&i then c&i=1;

jj.PNG (23.79 KB)

jj.PNG

12楼
marakesh 发表于 2018-5-11 20:46:43
试试这一段。可惜就是写的有点长。
data test;
input id var:$80.;
datalines;
2 57,2,7,9,16,35
1 .
3 17
4 5
5 21,55
6 9,39,58,60
;
run;
%macro query(dataset=);
proc sql noprint;*计算受试者id的数量;
select count(id) into:idnumber
from &dataset.;
quit;

%do n=1 %to &idnumber.;*把不同id的受试者分到不同数据集中;
data data_1_&n.;
  set &dataset.;
   %do i=1 %to 60;
    var&i.=scan(var,&i.,',');
   %end;
  where id=&n.;
run;

proc transpose out=data_2_&n. data=data_1_&n.;*转置;
  var var1-var60;
run;
%end;

data total;run;
%do j=1 %to &idnumber.;*把数据集叠加起来;
data total;
  set total data_2_&j.;
  if col1='' then delete;
run;
%end;

proc sql noprint;*生成数据集,lbtest对应检查项,count对应阳性数量;
create table count as
select col1 as lbtest,count(col1) as count
from total
group by col1
quit;
%mend;
%query(dataset=test);

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

客服
GMT+8, 2026-12-3 17:10