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

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

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
  • 3 replies
  • 1133 views
  • 0 likes
  • 2 in conversation