全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
3290 1
2016-10-10
高手们,我有一道题想请教大家。Assume you have a data set of claims, we would like to know the data that each beneficiary has met the required deductible payment of $275. Assume the data set includes claims data from 2008 and has an observation for each beneficiary with the following variables:a. BENE_ID: this is identified each beneficiary uniquelyb. Claim_Dt: date of the prescription drug claim, in SAS/ Stata data formatc. Drug_cost: cost of the drug which contributes to the deductiblePlease sketch out a program that would determine the date of the claims that puts the individual over the deductible $275, i.e., when the cumulative total drug cost year to date exceeds $275.我只知道要做累计求cost,应该用 lag在sas里。希望大神们给出具体解题思路和programming 步骤。重要重要!拜托了~~
二维码

扫码加我 拉你入群

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

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

全部回复
2016-10-10 16:15:20
看得心累 这截的一段前后没说明白。 变量有ID ,日期(日频?月频?年度的?),对应日期的cost。你是要求啥?每年cost总和大于275的ID?还是cost总和大于275的ID(不用管年份只要都加起来)?总之大概是对每个ID求和的意思?
先把所有数据横向合并到一起(这里貌似已经在一张data set里了,就不用这一步了)
然后
proc sort data=?;
by id date;
run;
如果每个ID的数据比较小(比如月频数据,只要求年度总和),那你用lag 和array(),
data fx2;
set fx;
array arr(*) h1-h12;
arr(1)=cost;
do i=2 to 12;
arr(i)=lag(arr(i-1));
end;
drop i;
run;
然后横着把12个月的cost都加起来就好了(这里面会有每个ID相邻的那里出现前一个ID和后一个ID的cost加起来的没意义的情况,反正你只要选每个ID最后那个和(用first. 和last. 语句找)就行了 其它全部drop)。

要是数据太多(比如日频数据让你求年度总和)的话......再说吧......
二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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