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


I have one variable 'birthd' that shows value in character format (e.g. 19890629). I want to convert that into a date variable mmddyy in the same file work.test.

Attached is the below code - the variable date_new shows up as numeric instead of date format.

Much help appreciated.

Thanks,

Neil.

WORK.merged;

WORK.merged_COPY;

date_new = input(birthd, yymmdd8.);

format date_new date10.;

run;

1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

It works for me.

A SAS date value gets stored in a numeric variable as number of days since 01Jan1960 with a format attached.

data test;

  birthd='19890629';

  date_new = input(birthd, yymmdd8.);

  format date_new date10.;

run;

View solution in original post

3 REPLIES 3
Patrick
Opal | Level 21

It works for me.

A SAS date value gets stored in a numeric variable as number of days since 01Jan1960 with a format attached.

data test;

  birthd='19890629';

  date_new = input(birthd, yymmdd8.);

  format date_new date10.;

run;

Reeza
Super User

What do you mean by numeric rather than date format?

SAS has only two variable types, numbers and characters and a "date" variable is a number with a date format, specifically the number of days from Jan 1, 1960.

Tom
Super User Tom
Super User

If you want the dates to display in month,day, year format then use a format that will do that.  For example for today (06JAN2014)  to display as 06012014 you would use:

format date_new mmddyyn8.;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 170117 views
  • 9 likes
  • 4 in conversation