全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
7112 13
2013-06-11
想编出一个提取数据的宏,filed 是变量名, list是我们想要的值,dsin和dsout分别是input 和output, 代码很简单,如下:
%macro
ExtractICD9(field, list, dsin, dsout);
proc sql;
create table &dsout as
select * from &dsin
where &field in &list;
quit;
%mend ExtractICD9;
现在有3个问题:(1)如果field取值超过了1, 变成了一个list,如(a,b,c),那么代码就不能运行了……(2)如果list中的值很多,储存在一个txt文件中,不便于一个一个输入,能做到直接读取txt文件得到list的值吗?也就是说此代码中的宏变量由list变成了path(txt文件的路径)。(3)txt中的list值,很可能出现类似433x1的情况,意味着我们要找43301, 43311, 43321,43331,43341,43351,43361,43371,43381,43391,即x意味着所有0-9取值。这三个SAS问题感觉都比较难,而且不是很常见,大家对其中任意一个有想法也请发表宝贵意见,在下不胜感谢。

二维码

扫码加我 拉你入群

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

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

全部回复
2013-6-11 10:23:03
嗯,确实比较难!
二维码

扫码加我 拉你入群

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

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

2013-6-11 11:20:04
在data步中用array应该可以吧,list的值如果全部在txt文件里的话,先处理一下。。。
二维码

扫码加我 拉你入群

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

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

2013-6-11 22:04:16
问题1和3是可以解决的,就是麻烦一点儿
复制代码
问题2的话觉得在macro外import成data,然后生成macro变量。

总之,觉得很麻烦,不知道有没有简单的方法
二维码

扫码加我 拉你入群

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

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

2013-6-12 00:51:41
个人理解,不知合不合要求,很多细节没处理好,多多指教。。。 (list。txt里面的值是4、5、6)。。。
复制代码
二维码

扫码加我 拉你入群

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

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

2013-6-12 02:46:03
ICD-9 diagnosis code are usually between 3 to 5 characters (most are digits), so don't go beyond 5 digits guys. http://www.icd9data.com/2013/Volume1/default.htm
As I recall, University of Manitoba has some sample code here (not great but a good start for the OP)
http://mchp-appserv.cpe.umanitob ... .php?conceptID=1098

OP's question (1) and (2) have already been very well addressed by Board Of Education and yuerqieie. But usually the complete list of ICD-9 codes are not given for a certain disease or condition. For example, your boss may say drug dependency is identified by 304.xx. Do you really want to go through the ICD-9 code book to create yourself a complete list of 5-digit subcodes and write them into a text file, or you'd rather match the first 3 digits only? Also the DX code in your patient database may not be entered as specific as 5 digits, so you have to put the parent code in your list as well. Question (3) is rather simple, you may put
复制代码
My point is, you cannot go 100% precise for the subject. I'd rather sacrifice accuracy by using the Manitoba approach so I can sleep better.
二维码

扫码加我 拉你入群

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

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

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

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