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

Hello,

I've a text variable that looks like this:

period
2019-01-01T15:00:00.0/2019-01-01T16:00:00.0
2019-01-01T16:00:00.0/2019-01-01T17:00:00.0

but I'd like to exclude first part of this text to the 2 new vars (date in yymmdd10. format and hour as intg) like bellow:

period date hour
2019-01-01T15:00:00.0/2019-01-01T16:00:00.0 2019-01-01 15
2019-01-01T16:00:00.0/2019-01-01T17:00:00.0 2019-01-01 16

How can I achieve this one?

1 ACCEPTED SOLUTION

Accepted Solutions
PatrykSAS
Obsidian | Level 7

Ok, I've done simple substr and it works

input(substr(t1.__Observation_period,1,10),yymmdd10.)

View solution in original post

2 REPLIES 2
PatrykSAS
Obsidian | Level 7

Ok, I've done simple substr and it works

input(substr(t1.__Observation_period,1,10),yymmdd10.)

ballardw
Super User

The E8601DTw.d informat will read those values into a single datetime variable as well if of interest.

 

You might also test what happens without the Substr and just use

input(t1.__Observation_period,yymmdd10.)

 

The length on an informat controls how many characters are read. This is "nice" data where the first 10 characters are in a common layout, no 1 digit month or day of month values.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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