- Get link
- X
- Other Apps
EXTRACTION OF DATEPART | TIMEPART FROM SAS DATE
Function: DATEPART
Purpose: To compute a SAS date from a SAS datetime value.
Syntax: DATEPART(date-time-value)
Function: TIMEPART
Purpose: To extract the time part of a SAS datetime value.
Syntax: TIMEPART(date-time-value)
CODE:
data pieces_parts;
DT = '01jan1960:7:15:30'dt;
Date = datepart(DT);
Time = timepart(DT);
format DT datetime. Time time. Date date9.;
run;
title "Listing of Data Set PIECES_PARTS";
proc print data=pieces_parts noobs;
run;
Explanation:
The DATEPART and TIMEPART functions extract the date and the time from the datetime
value, respectively. These two functions are especially useful when you import data from
other sources.We can use these two functions to separate the date and time from that value.
OUTPUT:
Listing of Data Set PIECES_PARTS |
DT | Date | Time |
---|---|---|
01JAN60:05:15:30 | 01JAN1960 | 7:15:30 |
TRY THIS AND COMMENT ...
--PLEASE FOLLOW THE BLOG FOR MORE UPDATES...
--FOLLOW US IN FACEBOOK SASALL4YOU AND JOIN ...
--JOIN US IN FACEBOOK AND TELEGRAM CHANNEL FOR MORE UPDATES
CLICK HERE: https://t.me/SasAll4You
- Get link
- X
- Other Apps
Comments
Post a Comment