converting to_char in sql to sas (proc sql)and format date
to_char is not a SAS function. You can get the date from a datetime using the datepart function.
proc sql;
select
datepart(b.cre_date) as Cdate format=yymmddd10.
If you want to convert it from date to character you need to use the put statement with the correct format, in your case yymmddd10.
proc sql;
select
put(datepart(b.cre_date),yymmddd10.) as Cdate
Frazz
I've started programming when I was 12... and that was way back when computers did not have monitors... over 35 years ago. That actually means I'm old :( Basic, C, ObjectPascal (aka Delphi), Java, JSP, PHP... I've tried a lot of languages and I still like to learn some new tricks. I've mostly worked on databases, client-server and multi-tier applications. I've also done some years on data warehouses, especially in SAS. I now live in Italy, but I spent some years in England and in the States... and that is where I picked up my only sport passion... baseball :)
Updated on November 26, 2022Comments
-
Frazz over 1 year
proc sql outobs=100; select to_char(b.cre_date,'YYYY-MM-DD') as CDate,** b.sub_id, c.subs_name, quit;
I am trying to run the above code in sas eg..but I am unable to use the to_char function in proc sql. the logic is I need to format cre_date as yyyy-mm-dd the present date is in datetime25.6 informat. and also suggest me a replacement for to_char in proc sql
thanks,
-
Frazz almost 10 yearsIt's been a while since I worked with these things. Can't you just use PUT(b.cre_date,$someformat.) AS CDate? What have you tried?
-