BookmarkSubscribeRSS Feed
saskishore
Calcite | Level 5

I Have data set with below data example format,

I want to ouput in disinct member who is having service date and with in days and status. I am using below code. but I am still  in correct data. Thank you in advance.

 

I need final data to be like below

Mbr_ID  F_NM  L_NM  CLM_TYP  SRVC_DT  DAYS  CMPL_STS

111         A          Z            LAB              1/1/22        21       with in 40 days 

123        B          Y            MED             2/2/22        41       After 40 day

 

Actual data in table

Mbr_ID  F_NM  L_NM  CLM_TYP  SRVC_DT  DAYS  CMPL_STS

111         A          Z            LAB              1/1/22        21       with in 40 days 

111         A          Z            MED                                          not meeting condition

123        B          Y            LAB                                           not meeting condition

123        B          Y            MED             2/2/22        41       After 40 day

 

Code

proc sort data =a;

by mbr_id  SRVC_DT  DAYS;

quit;

 

data b;

set a;

by mbr_id  SRVC_DT  DAYS;

if first.mbr_id and first.sevc_dt and first.days;

run;

 

2 REPLIES 2
andreas_lds
Jade | Level 19

It is not clear what you have and what you want, also please post data in usable form.

 

Maybe you all you need is a where statement:

data want;
  set have;
  where not missing(SRVC_DT) and not missing(DAYS);
run;
PeterClemmensen
Tourmaline | Level 20

I don't think it is clear what you're trying to do. However, I think this is close.

 

data have;
input Mbr_ID F_NM $ L_NM $ CLM_TYP $ SRVC_DT :ddmmyy10. DAYS CMPL_STS :$50.;
infile datalines dlm = '|';
format SRVC_DT ddmmyy10.;
datalines;
111|A|Z|LAB|1/1/22|21|with in 40 days       
111|A|Z|MED|      |  |not meeting condition 
123|B|Y|LAB|      |  |not meeting condition 
123|B|Y|MED|2/2/22|41|After 40 day          
;

proc sql;
   create table want as
   select distinct *
   from have
   where SRVC_DT and DAYS
   group by Mbr_ID
   having max(SRVC_DT) = SRVC_DT
   ;
quit;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 2 replies
  • 261 views
  • 0 likes
  • 3 in conversation