楼主: katezhong
3338 1

SAS lag() 语句 [推广有奖]

  • 0关注
  • 0粉丝

大专生

23%

还不是VIP/贵宾

-

威望
0
论坛币
35 个
通用积分
1.8513
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
948 点
帖子
54
精华
0
在线时间
21 小时
注册时间
2012-2-25
最后登录
2022-9-11

楼主
katezhong 发表于 2016-10-10 14:16:15 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
高手们,我有一道题想请教大家。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 步骤。重要重要!拜托了~~
二维码

扫码加我 拉你入群

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

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

关键词:lag Prescription observation contributes Programming identified following includes required payment

沙发
风晚凉 发表于 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)。

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

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

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