user3675327
user3675327

Reputation: 31

converting to_char in sql to sas (proc sql)and format date

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,

Upvotes: 2

Views: 28341

Answers (1)

Laurent de Walick
Laurent de Walick

Reputation: 2174

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

Upvotes: 2

Related Questions