DATA Step, Macro, Functions and more

iso 8601 format for missing dates

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 100
Accepted Solution

iso 8601 format for missing dates

Can someone help me with the code to convert this numberic date format to ISO8601 fomat (like17OCT2016 2 time 9:10:04 to 2016-10-17T09:10:04), but I want to have a generic code even for missing date or month or both . I am trying to Converting Non-Imputed Partial Dates for a sdtm dataset. how to delete the wrong numbers for time notation (like hours upto 24, minutes upto 60, upto 60 sec etc) 

eg:

2016-10-17T09:10:04
2016-10--T09:10:04
2016----T09:10:04
2016-10-17T-:10:04
2016-10--T09:10:04
2016----T09:10:04

2016-10-17T00:10:04
2016-10-17T09:00:04
2016-10-17T09:10:00

                  please correct me if this notation is wrong in sdtm ISO 8601 fomat?

 


Accepted Solutions
Solution
‎04-27-2017 06:31 AM
Senior User
Posts: 1

Re: iso 8601 format for missing dates

Hi

 

check below link if you can locate solution for your problem

 

http://www.lexjansen.com/nesug/nesug10/ph/ph11.pdf


buddha_d wrote:

Can someone help me with the code to convert this numberic date format to ISO8601 fomat (like17OCT2016 2 time 9:10:04 to 2016-10-17T09:10:04), but I want to have a generic code even for missing date or month or both . I am trying to Converting Non-Imputed Partial Dates for a sdtm dataset. how to delete the wrong numbers for time notation (like hours upto 24, minutes upto 60, upto 60 sec etc) 

eg:

2016-10-17T09:10:04
2016-10--T09:10:04
2016----T09:10:04
2016-10-17T-:10:04
2016-10--T09:10:04
2016----T09:10:04

2016-10-17T00:10:04
2016-10-17T09:00:04
2016-10-17T09:10:00

                  please correct me if this notation is wrong in sdtm ISO 8601 fomat?

 



buddha_d wrote:

Can someone help me with the code to convert this numberic date format to ISO8601 fomat (like17OCT2016 2 time 9:10:04 to 2016-10-17T09:10:04), but I want to have a generic code even for missing date or month or both . I am trying to Converting Non-Imputed Partial Dates for a sdtm dataset. how to delete the wrong numbers for time notation (like hours upto 24, minutes upto 60, upto 60 sec etc) 

eg:

2016-10-17T09:10:04
2016-10--T09:10:04
2016----T09:10:04
2016-10-17T-:10:04
2016-10--T09:10:04
2016----T09:10:04

2016-10-17T00:10:04
2016-10-17T09:00:04
2016-10-17T09:10:00

                  please correct me if this notation is wrong in sdtm ISO 8601 fomat?

 


 

View solution in original post


All Replies
Respected Advisor
Posts: 3,799

Re: iso 8601 format for missing dates

Show what you have and what you want.

Frequent Contributor
Posts: 100

Re: iso 8601 format for missing dates

Posted in reply to data_null__

I want to have a generic code for any missing value in the format 

Super User
Posts: 11,343

Re: iso 8601 format for missing dates

Are you attempting to create SAS datetime values? SAS will not allow creation of a date/datetime with missing components such as month or day the value would always have an assumed month/day. For instance, if you want a SAS datetime value, 2016----T09:10:04 would require something for day and month. Could it be that for your data you want to use the month or day of the month from the previous record (assuming this data is collected in some sort of sequence)?

 

 

Frequent Contributor
Posts: 100

Re: iso 8601 format for missing dates

I don't want to impute anything for the missing date or time values. But this is what i want.

 

INPUT DATA:
17OCT2016 9:10:04
UNOCT2016 9:10:04
UNOWN2016 9:10:04
17OCT2016 :10:04
UNOCT2016 9::04
UNOWN2016 9:10:

 

output should look like this
2016-10-17T09:10:04
2016-10--T09:10:04
2016----T09:10:04
2016-10-17T-00:10:04
2016-10--T09:00:04
2016----T09:10:00

Solution
‎04-27-2017 06:31 AM
Senior User
Posts: 1

Re: iso 8601 format for missing dates

Hi

 

check below link if you can locate solution for your problem

 

http://www.lexjansen.com/nesug/nesug10/ph/ph11.pdf


buddha_d wrote:

Can someone help me with the code to convert this numberic date format to ISO8601 fomat (like17OCT2016 2 time 9:10:04 to 2016-10-17T09:10:04), but I want to have a generic code even for missing date or month or both . I am trying to Converting Non-Imputed Partial Dates for a sdtm dataset. how to delete the wrong numbers for time notation (like hours upto 24, minutes upto 60, upto 60 sec etc) 

eg:

2016-10-17T09:10:04
2016-10--T09:10:04
2016----T09:10:04
2016-10-17T-:10:04
2016-10--T09:10:04
2016----T09:10:04

2016-10-17T00:10:04
2016-10-17T09:00:04
2016-10-17T09:10:00

                  please correct me if this notation is wrong in sdtm ISO 8601 fomat?

 



buddha_d wrote:

Can someone help me with the code to convert this numberic date format to ISO8601 fomat (like17OCT2016 2 time 9:10:04 to 2016-10-17T09:10:04), but I want to have a generic code even for missing date or month or both . I am trying to Converting Non-Imputed Partial Dates for a sdtm dataset. how to delete the wrong numbers for time notation (like hours upto 24, minutes upto 60, upto 60 sec etc) 

eg:

2016-10-17T09:10:04
2016-10--T09:10:04
2016----T09:10:04
2016-10-17T-:10:04
2016-10--T09:10:04
2016----T09:10:04

2016-10-17T00:10:04
2016-10-17T09:00:04
2016-10-17T09:10:00

                  please correct me if this notation is wrong in sdtm ISO 8601 fomat?

 


 

Frequent Contributor
Posts: 100

Re: iso 8601 format for missing dates

Posted in reply to Geethakrishna

Thanks all for your input. 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 158 views
  • 0 likes
  • 4 in conversation