为了账号安全,请及时绑定邮箱和手机立即绑定

SAS Space

标签:
MySQL 大数据

SAS Day 24: Space Trick

Background:

My boss has a motto “Devil in the details”. I think all the Space- Related issues are the “Devil” in SAS.

Today, we will go over the function and tricks I used to deal with Space.

  • Remove Space: Compress, Compbl, Strip, Trim
  • Concatenate with Remove Space: ||, CAT, CATS, CATX, CATT

[caption id=“attachment_1626” align=“alignnone” width=“550”]image

analogicus / Pixabay[/caption]

Group 1: Compress, Compbl, Strip, Trim

1.Compress: Remove all the blanks by default, it can remove any specified characters as well.

2.Compbl: Compress multiple blanks into a single blank

3.Strip: Remove Leading and Trailing Blanks

4.Trim: Remove Trailing blank

Example:

image

Code:

data test;
input first $ last $ tel $29.;
datalines;
 Mary Smith  61 5- 999-   2222   
Keith O 777-2  22- 1234 
Jay Chou 4 15-221-99 98
Lionel Messi 312-45 6-1111 
Chris Wu 480 -9 00-87 63 
;
run;

data space;
set test;
compress=compress(tel,"-");
compbl=compbl(tel);
strip=strip(tel);
trim= trim(tel);
run;

Group 2: ||, CAT, CATT, CATS, CATX

||: directly concatenates character strings without modification.

CAT: concatenates character strings with leading or trailing space

CATT: concatenates character strings and removes trailing blanks

CATS: concatenates character strings and remove trailing and leading blanks

CATX: concatenates character strings and remove trailing and leading blanks, and inserts a separator between each string.

image

Code:

data sample;
set test;
direct=first||last;
cat=cat(first,last);
catt=catt(first,last);
cats=cats(first,last);
catx=catx(".", first, last);
run;

Ref:https://www.lexjansen.com/nesug/nesug09/cc/CC25.pdf

Happy Studying! ☕

点击查看更多内容
TA 点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
  • 推荐
  • 评论
  • 收藏
  • 共同学习,写下你的评论
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消