linux 存储sas scan,SAS Scan

SAS Day 4:

I came across a very interesting variable structure, AEENDTH combined AEENDT(adverse event end date) and DEATHDT (death date) together.

For example,2008-04-21/2008-05-12

Problem:

We want the select the non-missing death date (second date), however, if the death date is missing, we will select the adverse event end date (first date) as the death date.

Before we solve the problem, we need to go over a couple of SAS Functions:SCAN, TRANWRD

SCAN:separate a character value into words and return a specified word

Example:

a= TF-BOY101000-001-1000

b=Scan(a,3, '-');

Note: Take the third word separated by "-".

Return:001

TRANWRD:substitute strings for a certain part of the variable

Example:

Add=‘No.88 KeyuanRoad’;

Add =TRANWRD(Add,'Road','Rd.');

Note: replace Road with Rd.

Return: No.88 KeyuanRd.

[caption id="attachment_229" align="alignnone" width="1280"]

janjf93/ Pixabay[/caption]

3d1a50811a8a?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendation

Solution:

1. ApplyTranwrdfunction to replace "/" with "|"

2. ApplyScanfunction from last digit (-1) until the "|"

3. ApplyInputfunction to convert the time to numerical, and use ?? to      avoid log warnings

Code:

1.aeendth=tranwrd(aeendth,"/","|");

2.deathdt=input(scan(aesdthd,-1,'|'),??IS8601DA.);

Note: We shouldNOTuse (scan(aesdthd,2,'|'), because some records only have a date,2008-03-21/

Thanks to 77, she started to summarized the SAS functions and shared it with me :)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值