Click here to Skip to main content
14,428,471 members
Rate this:
Please Sign up or sign in to vote.
See more:
Thank you in advance, need to translate the below SAS code to R code. This would be for a great help.

/*get all distinct main cpts from CMS data*/
proc sql;
create table cms_filter as
select distinct main_cpt from cms;
quit;

/*Get the enc numbers and cpt code from the aging data for the main cpts from CMS_filter*/
proc sql;
create table merge_1 as
select distinct enc_nbr,cpt4_code_id from aging where cpt4_code_id in
(select distinct main_cpt from cms_filter);
quit;


proc sql;
create table aging_2 as
select a.*,b.cpt4_code_id as main_cpt from aging as a
left join
merge_1 as b
on
a.enc_nbr =b.enc_nbr ;
quit;

proc sql;
create table final as
select a.enc_nbr,b.main_cpt,b.child_cpt from
aging_2 as a
join
cms as b
on
a.min_cpt=b.main_cpt and
a.cpt4_code_id=b.child_cpt;
quit;

What I have tried:

I don't know SAS. So, couldn't work on my own
Posted

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

Hi,
I know both SAS and R and can help translate it to you.
But this post a little old.
So if it is still actual, please, write me via mail:
bestuser@mail.ru, topic: 'sas into R'

Thanks,

Step 0;
#get data into R


Step 1;
/*get all distinct main cpts from CMS data*/
cms_filter <- data.frame( main_cpt = unique( cms$main_cpt ) )
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100