01-29-2014 10:09 AM
I am working on a program to display datetime variables with missing day/month/second information. The questions I have are
01-29-2014 11:12 AM
First, to make use of SAS datetime values, a part of the datetime can't be 'missing'. The same should be valid from any reliable source system. If your datetime values have missing part, I assume they are in char format. This sounds like a candidate for char tweaking, not nay processing that includes SAS dateime function/formats.
What does your input look like?
1) In this case, convert to SAS datetime value by using a standard informat (depending on the format of your input data), Now, you can write your own picture format, which let's you do some formatting/logic, there are quite few directives that help you manipulate datetime values.
2) Can't se how this could work wit SAS date/datetime values, since they are numerical values that count days/seconds from 1Jan19060. So, here you probably need to do some character manipulating logic.
01-29-2014 11:14 AM
I don't know if what you are trying to do is possible and still retaining the numeric aspect of date/time variables. You would have to change them to character values and then do a "find and replace" (probably using the SUBSTR() function). But this takes away all ability to use dates and time for their true nature. You won't be able to properly sort or find differences between dates any more.
01-29-2014 02:43 PM
hi please see if this is what you want;program will also take care of consecutive missing months.
input date_have :datetime21.;
format date_have datetime21.;
if dif(datepart(date_have))>1 then
do i=1 to diff-1;
proc sort data=test;
if missing=1 then date_want=catx('/',put(datepart(date_have),monyy7.),'UNKNOWN');