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