BookmarkSubscribeRSS Feed
Vijay77
Fluorite | Level 6

I have a following date i have to convert it to numeric and iso8601 format

 

UN-UNK-1975

UN-OCT-1986

18-OCT

 

Expected o/p:

1975

10-1986

.

Thanks

 

3 REPLIES 3
SASKiwi
PROC Star

1975 and 10-1986 are not valid dates in any format - a date requires a day, month and a year. If you only know the year 1975 what would you default your date to? 01-01-1975? Similarly does 10-1986 become 01-10-1986?

Shmuel
Garnet | Level 18

You need more examples in order to define the algorithm.

I suggest to locate in your input:

1) A 4 digits sub-string  assumed as a year

2) A 3 characters sub-string to be checked against a list or by a format

    containing all months (JAN FEB MAR ...)

3) Is there in your input full name month? (JANUARY FEBRUARY ...) or

    mixed case like January February ... ? or month given in digits ?

    If answer is positive you need more code in the algorithm.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 1181 views
  • 3 likes
  • 4 in conversation