Date Format

Reply
Frequent Contributor
Posts: 138

Date Format

Hi,

Im trying to change the date from dd/mm/yyyy to yyyy but my code doens't work. The field presents the data dd/mm/yyyy but the column properties show different.

The column properties are -

length 8

format ddmmyy

informat 10.

My code -

proc sql;

create table work.green as

select

curr_term_exp as maturity format=yyyy.

from work.green;

quit;

Any ideas please?

Esteemed Advisor
Esteemed Advisor
Posts: 7,223

Re: Date Format

Try yearpart() function.

Trusted Advisor
Posts: 1,203

Re: Date Format

proc sql;

create table work.green as

select

curr_term_exp as maturity format=year.

from work.green;

quit;

Regular Contributor
Posts: 233

Re: Date Format

data green;
format curr_term_exp ddmmyy10.;
informat curr_term_exp ddmmyy10.;
input curr_term_exp $;
cards;
1/1/2013
1/1/2014
1/1/2015
;
run;

proc sql;
  select curr_term_exp as maturity format=year4. from work.green;
quit;

Capture.JPG

Super User
Super User
Posts: 6,351

Re: Date Format

If you want to display it differently then just attach the YEAR format.

If you want to make a new variable that only has year then use the YEAR() function.

Ask a Question
Discussion stats
  • 4 replies
  • 232 views
  • 0 likes
  • 5 in conversation