Help using Base SAS procedures

Unable to convert a number to a SAS Date.

Posts: 66

Unable to convert a number to a SAS Date.


I am trying to convert a number to a SAS Date YYMMDD8. I m using proc Sql; from Oracle table  to BASE SAS table.

Input(put(date,8.),yymmdd8.) as Descn_date,

I have around 80 columns and around 30 columns have date as number for e.g 20150306 and so

I m not able to convert it

Pls help me on this.

Trusted Advisor
Posts: 1,137

Re: Unable to convert a number to a SAS Date.

could you please try this

put(Input(date,yymmdd8.),yymmdd8.) as Descn_date

Posts: 7,417

Re: Unable to convert a number to a SAS Date.

If your date field actually contains just numbers like (20151003) then your code should have worked. Does your log provide any clue?

Conversely, is there a chance they are really numbers represented as a string?

If so, you could use something like:

proc sql noprint;

  create table want as

    select Input(date,yymmdd8.) as Descn_date format=date9.

      from have



Super User
Super User
Posts: 7,565

Re: Unable to convert a number to a SAS Date.

Well, there are a few things here.  Firstly, by proc sql from oracle table, does this mean you are using pass through and executing statements on the Oracle server?  If so you probably wont be able to use SAS functions.  Also, the "date" from Oracle is different.

I would suggest that you start by extracting the data as it is to a SAS dataset:

proc sql;

     connect to oracle ...;

     create table TMP as

     select * from connection to oracle (

          select * from SCHEMA.YOU_TABLE);

     disconnect from oracle;


Now examine the data you have got back.  The dates can processed using normal SAS techniques:

data tmp;

     set tmp;



I don't have an Oracle server here so can't check any of the above, but that is what I think you are getting stuck on.

Ask a Question
Discussion stats
  • 3 replies
  • 4 in conversation