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

Hi Everyone,

 

Can some one help me with extracting DAY, MONTH, YEAR and Time from the below format....

 

2015-08-27T 8:36:00

2014-09-30T14:45:00

 

The output should look like this…

       STDTC                           ST_Y ST_M ST_D ST_TM

2015-08-27T 8:36:00       2015   8   27   08:36

2014-09-30T14:45:00      2014  9    30   14:45

 

Thanks in advance

 

Rakesh

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

1. Datepart() function to extract date

2. Timepart() function to extract time

3. Year(), Month(), Day() function to extract date components - reference variable from #1

View solution in original post

2 REPLIES 2
Reeza
Super User

1. Datepart() function to extract date

2. Timepart() function to extract time

3. Year(), Month(), Day() function to extract date components - reference variable from #1

DartRodrigo
Lapis Lazuli | Level 10

Hi mate,

 

Try this. Not the best option but works:

 

data dt;
  date="2015-08-27T 8:36:00 ";
run;

data dt2;
   set dt;
   ST_Y  = input(scan(date,1,"-"),Year.);
   ST_M  = input(scan(date,2,"-"),month.);
   ST_D  = input(scan(scan(date,1,"T"),3,"-"),day.);
   ST_TM = input(scan(date,2,"T"),nltime10.);
   format ST_TM nltime10.;
run;

Hope this helps

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 70346 views
  • 5 likes
  • 3 in conversation