BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
127
Fluorite | Level 6 127
Fluorite | Level 6

hello, 

Looking to create a new dataset with the "whole" claim for specific Procedure Code G102 or G103 as being "denied" based on the date of service (DOS). 

 

Any help with SAS code would be great!  Here's an example with fake data: 

IDClm1stDOSProcCodeStatusWantData
1011/1/2015G102Paid Keep
1011/1/2015G102Paid Keep
1011/1/2015G102Denied  Keep
1012/18/2015G102Paid Keep
1012/18/2015G103Denied new dataset
1012/20/2015G103Paidkeep
1012/20/2015G102Denied new dataset
1012/20/2015G102Denied new dataset
1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

HI @127  By any chance, you are after this?

 

data have;
input ID	Clm1stDOS :mmddyy10.	(ProcCode	Status) ($);*	WantData;
format Clm1stDOS mmddyy10.;
cards;
10	11/1/2015	G102	Paid 	Keep
10	11/1/2015	G102	Paid 	Keep
10	11/1/2015	G102	Denied  	Keep
10	12/18/2015	G102	Paid 	Keep
10	12/18/2015	G103	Denied 	new dataset
10	12/20/2015	G103	Paid	keep
10	12/20/2015	G102	Denied 	new dataset
10	12/20/2015	G102	Denied 	new dataset
;

data keep new;
 do _n_=1 by 1 until(last.ProcCode);
  set have;
  by id Clm1stDOS ProcCode notsorted;
  if status='Denied' then _n=sum(_n,1);
 end;
 if _n_=_n then  _f=1;
 do _n_=1 to _n_;
  set have;
  if _f then output new;
  else output keep;
 end;
 drop _:;
run;

View solution in original post

4 REPLIES 4
PeterClemmensen
Tourmaline | Level 20

I don't understand the logic here. Can you be a bit more specific?

127
Fluorite | Level 6 127
Fluorite | Level 6

Claim with the same DOS can have multiple lines with same or different proc codes and sometimes they get paid and sometimes denied. I want to group the claim as a "whole claim" by their DOS and ProcCode then if the whole claim for the same DOS and same Proc code got denied every time then I want to exclude into separate database. 

 

 

novinosrin
Tourmaline | Level 20

HI @127  By any chance, you are after this?

 

data have;
input ID	Clm1stDOS :mmddyy10.	(ProcCode	Status) ($);*	WantData;
format Clm1stDOS mmddyy10.;
cards;
10	11/1/2015	G102	Paid 	Keep
10	11/1/2015	G102	Paid 	Keep
10	11/1/2015	G102	Denied  	Keep
10	12/18/2015	G102	Paid 	Keep
10	12/18/2015	G103	Denied 	new dataset
10	12/20/2015	G103	Paid	keep
10	12/20/2015	G102	Denied 	new dataset
10	12/20/2015	G102	Denied 	new dataset
;

data keep new;
 do _n_=1 by 1 until(last.ProcCode);
  set have;
  by id Clm1stDOS ProcCode notsorted;
  if status='Denied' then _n=sum(_n,1);
 end;
 if _n_=_n then  _f=1;
 do _n_=1 to _n_;
  set have;
  if _f then output new;
  else output keep;
 end;
 drop _:;
run;
127
Fluorite | Level 6 127
Fluorite | Level 6
An elegant solution. thank you!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 506 views
  • 1 like
  • 3 in conversation