全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
4499 4
2018-08-10
/*去除字符串头尾分号的三种方法*/
data test;
   x=';;;中国;美国;日本;;;;;;';
   y1=Translate(strip(Translate(x,' ',';')),';',' ');   /*前提:字符串中不含空格*//*此法效率最高*/
   y2=substr(x,findc(x,';','k'),findc(x,';','bk')-findc(x,';','k')+1);
   y3=prxchange('s/^;*([^;].*[^;])(;+)?$/$1/o',1,x);
run;

二维码

扫码加我 拉你入群

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

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

全部回复
2018-8-11 00:49:07
学习了
二维码

扫码加我 拉你入群

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

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

2018-8-16 11:01:39
学习了.
二维码

扫码加我 拉你入群

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

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

2018-8-16 12:00:15
螃蟹哥厉害 膜拜
二维码

扫码加我 拉你入群

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

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

2018-10-22 10:49:16
data test;
   input id $ time $ rna $1.;
cards;
1 1 1
1 2 0
1 3 0
1 4 0
1 5 0
2 1 1
2 2 0
2 3 0
2 4 1
2 5 0
3 1 1
3 2 0
3 3 1
3 4 1
3 5 1
;
run;

data want;
   set test;
   by id;
   retain temp1;
   if first.id then do;
      call missing(temp1);
      call missing(temp2);
   end;
   if rna=0 then temp1=1;
   if temp1=1 then temp2+rna;
   if last.id then do;
      if rna=1 then type='c';
      else if temp2=0 then type='a';
      else if temp2>0 then type='b';
   end;
run;
proc print;
run;


data want;
   set test;
   by id;
   length temp1 $100;
   retain temp1;
   if first.id then call missing(temp1);
   temp1=cats(temp1,rna);
   if last.id then do;
      if prxmatch('/^1*0+\s*$/o',temp1) then type='a';
      if prxmatch('/^1*0[01]*1[01]*0\s*$/o',temp1) then type='b';
      if prxmatch('/^1*0[01]*1\s*$/o',temp1) then type='c';
   end;
run;
proc print;
run;
二维码

扫码加我 拉你入群

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

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

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群