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.
could you please try this
put(Input(date,yymmdd8.),yymmdd8.) as Descn_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
;
quit;
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 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.