Help using Base SAS procedures

Formatting a Date

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 12
Accepted Solution

Formatting a Date

Hi all,

In one of the tables I refer to, the date appears as 31MAR2012:00:00:00.

How do I drop the time component of this and get the date as '31MAR2012'?

Thank you


Accepted Solutions
Solution
‎08-10-2011 11:56 PM
PROC Star
Posts: 7,363

Formatting a Date

If the field is already a SAS date_time field, then you only have to refer to it with a function, namely:

   date_you_want=datepart(whateverthedatetimefieldiscalled);

You also may want to add a format statement of the nature:

format date_you_want date9.

Of course, if the field is really only a string in a character variable, you would first have to input it using a datetime informat.

View solution in original post


All Replies
Solution
‎08-10-2011 11:56 PM
PROC Star
Posts: 7,363

Formatting a Date

If the field is already a SAS date_time field, then you only have to refer to it with a function, namely:

   date_you_want=datepart(whateverthedatetimefieldiscalled);

You also may want to add a format statement of the nature:

format date_you_want date9.

Of course, if the field is really only a string in a character variable, you would first have to input it using a datetime informat.

Occasional Contributor
Posts: 12

Formatting a Date

thank you Art, it worked. much appreciated.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 117 views
  • 0 likes
  • 2 in conversation