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?
Ok, I've done simple substr and it works
input(substr(t1.__Observation_period,1,10),yymmdd10.)
Ok, I've done simple substr and it works
input(substr(t1.__Observation_period,1,10),yymmdd10.)
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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.