Hello, I have tried to google this but am getting every other kind of solution but not to what I need, so am Hoping someone will be able to assist. I have a dataset that has Hospital Name, client ID, date of treatment and a flag. if there is no date of treatment for a client in a hospital then there is no row with the date. What i want to do is create a dataset that has a column that is consecutive dates for the full month and then the flag would be 1 or 0 for if there was a treatment. What I have is a table like this: Hospital_name Client_Id Date Flag A Tom 1/1/2022 1 A Tom 1/2/2022 1 A John 3/1/2022 1 A John 3/10/2022 1 B John 3/11/2022 1 B Joe 1/5/2022 1 B Joe 1/10/2022 1 B John 5/1/2022 1 C Sam 4/1/2022 1 C Sam 4/10/2022 1 What I would like is to do is add in the missing dates for each client for the whole month. So for example Tom was seen on 1/1/2022 and 1/2/2022 he has no visits for the remaining of January but I would like to add rows for Jan 3 to 31 where the flag=0 instead of 1. Joe in Hospital B was seen on 1/5/2022 and then again on 1/10/2022, but there are multiple dates in Jan for Joe he was not seen I would like to add the full month of Jan but out a flag=0 for those months he was not seen. Then do the same of the other clients by the Hospital. Here is the sas code to create the sample dataset: data have;
input Hospital_name $1. Client_Id $5. Date Flag $1.;
informat Date mmddyy10.;
format Date mmddyy10.;
cards;
A Tom 1/1/2022 1
A Tom 1/2/2022 1
A John 3/1/2022 1
A John 3/10/2022 1
B John 3/11/2022 1
B Joe 1/5/2022 1
B Joe 1/10/2022 1
B John 5/1/2022 1
C Sam 4/1/2022 1
C Sam 4/10/2022 1
;
run; I'm sure the solution is simple I am just not getting it. Thanks!
... View more