Jed
Jed

Reputation: 399

How do I extract the month and year from dates in a date column, within SAS?

I formatted the date column within my table, using the following code;

data data1;
set data;
format Date ddmmyy10.;
run;

I want to know how I can create a new column within my table which just extracts the month and year from the dates in the "Date" column.

How do I do this please?

Upvotes: 0

Views: 1489

Answers (1)

Artem  Glazkov
Artem Glazkov

Reputation: 26

in order to create new columns calculated by existing Date column you should try this:

data data1;
set  data;
format Date ddmmyy10.;
yearNo=year(Date);
monthNo=month(Date); 
run;

Upvotes: 0

Related Questions