1
votes
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,

1
It'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?Frazz

1 Answers

1
votes

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