Help using Base SAS procedures

Date Format

Accepted Solution Solved
Reply
Super Contributor
Posts: 1,041
Accepted Solution

Date Format


I have a numeric date variable with the format 11. in the dataset 20010813

How can I convert it to 13AUG2001?

Thanks


Accepted Solutions
Solution
‎03-18-2013 11:41 AM
Super User
Posts: 19,877

Re: Date Format

Posted in reply to robertrao

data have;

input current_date;

cards;

20010813

;

data want;

set have;

current_date=input(put(current_date, 8.), yymmdd8.);

format current_date date9.;

run;

This will display the date in a date9. format, but it still stored as a number underneath.

View solution in original post


All Replies
Solution
‎03-18-2013 11:41 AM
Super User
Posts: 19,877

Re: Date Format

Posted in reply to robertrao

data have;

input current_date;

cards;

20010813

;

data want;

set have;

current_date=input(put(current_date, 8.), yymmdd8.);

format current_date date9.;

run;

This will display the date in a date9. format, but it still stored as a number underneath.

Super Contributor
Posts: 578

Re: Date Format

Posted in reply to robertrao

If you have clean data (and most of us don't)...then you can use an input format to tell sas that you are reading in what you want to be considered a date variable.

data have;

informat current_date yymmdd8.;

format current_date date9.;

input current_date;

cards;

20010813

;

🔒 This topic is solved and locked.

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

Discussion stats
  • 2 replies
  • 288 views
  • 3 likes
  • 3 in conversation