楼主: l1i2n3i4n5g
4505 4

[程序分享] 去除字符串头尾分号的三种方法 [推广有奖]

已卖:51份资源

教授

25%

还不是VIP/贵宾

-

威望
0
论坛币
4511 个
通用积分
76.8946
学术水平
171 点
热心指数
204 点
信用等级
133 点
经验
24578 点
帖子
583
精华
1
在线时间
1865 小时
注册时间
2008-5-25
最后登录
2025-4-28

楼主
l1i2n3i4n5g 在职认证  发表于 2018-8-10 15:59:00 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
/*去除字符串头尾分号的三种方法*/
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;

二维码

扫码加我 拉你入群

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

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

关键词:效率最高 字符串

已有 2 人评分学术水平 热心指数 信用等级 收起 理由
eijuhz + 1 精彩帖子
whymath + 1 + 1 + 1 精彩帖子

总评分: 学术水平 + 1  热心指数 + 2  信用等级 + 1   查看全部评分

沙发
hsubin 在职认证  发表于 2018-8-11 00:49:07
学习了

藤椅
小明12345 发表于 2018-8-16 11:01:39
学习了.

板凳
albusdzx 发表于 2018-8-16 12:00:15
螃蟹哥厉害 膜拜

报纸
l1i2n3i4n5g 在职认证  发表于 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;

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

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-29 06:49