BookmarkSubscribeRSS Feed
yawenyu929
Fluorite | Level 6

Hello All,

 

I'm a new SAS user attempting to fill in some missing dates in my dataset. I have visits and visit numbers with corresponding start and end dates. I have all visit information, but not all dates:

 

yawenyu929_1-1596336007630.png

 

How can I add the missing datebased on visit without overwriting the existing ones? Also, gaps in dates are not consistent. Some subjects are missing one date, others are missing more. Any help would be appreciated! 

 

 

 

 

3 REPLIES 3
mkeintz
PROC Star

I don't understand what you want your output to look like.  Could you show what the output should look like, corresponding to the input you have provided?

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
yawenyu929
Fluorite | Level 6

Hello,

 

I'd my output to have all the missing dates filled in. If the last date is left off at 05Mar2020, then the next should be 06Mar2020, then 07Mar2020, then 08Mar2020, and so on until the next non-missing date. Hope this helps!

mkeintz
PROC Star

You have not provided a sas data step to reveal the names of your variables, and I am not going to make a data step out of your png file.  So here goes, assuming your date variable names are DATE1 and DATE2:

 

data want;
    set have;
    date1=coalesce(date1,lag(date1)+1);
    date2=coalesce(date2,lag(date2)+1);
run;
--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------

SAS Innovate 2025: Register Now

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!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1309 views
  • 0 likes
  • 2 in conversation