BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
chrisjab
Fluorite | Level 6

I am pulling comments that end with a date in the following format MM/DD/YYY and I'm trying to pull the dates to create a separate date column. I tried multiple formulas and I'm still not getting an output.

 

For example:

 

From the comments below, I am trying to pullout the dates:

- 10 Cans of Soda Safeway 05/10/2015

- 3 pounds of Salmon Whole Foods 06/17/2017 

 

One of the formulas I used is the following:

- SUBSTR(RIGHT(INPUT(t1.CommentsPrinted,32.)), 10.) 

 

Any help would be appreciated.

 

Thanks,

 

CJ

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

To create a character date, you might try:

 

scan(t1.CommentsPrinted, -1, ' ')

View solution in original post

3 REPLIES 3
Astounding
PROC Star

To create a character date, you might try:

 

scan(t1.CommentsPrinted, -1, ' ')

BrunoMueller
Meteorite | Level 14

Use the SCAN function with a negative index to get the rightmost text and then use the INPUT function with the proper informat to convert the char value to a SAS date value.

CFC_SAS_Communities_400x225.jpg

Call for content now open!

It's your turn to help shape SAS Innovate 2027. Share your expertise and inspire the SAS community.

Submit your proposal →

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 2758 views
  • 1 like
  • 3 in conversation