BookmarkSubscribeRSS Feed
santosh_pat69
Quartz | Level 8

Hi...

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.

3 REPLIES 3
Jagadishkatam
Amethyst | Level 16

could you please try this


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

Thanks,
Jag
art297
Opal | Level 21

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

  ;

quit;

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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;

quit;

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

data tmp;

     set tmp;

     new_date=input(substr(date,...),yymmdd8.);

run;

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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1091 views
  • 0 likes
  • 4 in conversation