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;
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;
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;
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.