## SAS DATES

Solved
Frequent Contributor
Posts: 147

# SAS DATES

I Have SAS dataset with the following variables. ID AND DATE IN YYYYMMDD format..

100030006  2015-10-06
100030006  2015-09-03
100030006 2015-08-19

I would like to output in the following way..with additional variable for day,month, year...

100030006  2015-10-06 6 10 2015
100030006  2015-09-03 3 9 2015
100030006 2015-08-19 19 8 2015

Can some one help on this.......

Thanks

Accepted Solutions
Solution
‎11-23-2015 10:26 AM
Super User
Posts: 9,599

## Re: SAS DATES

Assuming your date is actual a SAS numeric yymmdd. format variable then:

d=day(<your_date>);

m=month(<your_date>);

y=year(<your_date>);

If its not then you need:

y=year(input(<your_text_date>,yymmdd10.));

etc.

All Replies
Solution
‎11-23-2015 10:26 AM
Super User
Posts: 9,599

## Re: SAS DATES

Assuming your date is actual a SAS numeric yymmdd. format variable then:

d=day(<your_date>);

m=month(<your_date>);

y=year(<your_date>);

If its not then you need:

y=year(input(<your_text_date>,yymmdd10.));

etc.

Contributor
Posts: 26

## Re: SAS DATES

let me know if this works for you

data test;
input id dt;
attrib
dt informat = YYMMDD10. format= YYMMDD10.;
dt_day = day(dt);
dt_Mon = Month(dt);
dt_Yr = Year(dt);
datalines;
100030006 2015-10-06
100030006 2015-09-03
100030006 2015-08-19
;

run;

Valued Guide
Posts: 864

## Re: SAS DATES

Here you are:

data have;
informat id \$9. date yymmdd10.;
format id \$9. date yymmdd10.;
input id date;
cards;
100030006  2015-10-06
100030006  2015-09-03
100030006  2015-08-19
;

data want;
set have;
day = day(date);
month = month(date);
year = year(date);
run;

Frequent Learner
Posts: 1

## Re: SAS DATES

Hi,

You can try the following code:

data One;
informat ID \$9. date yymmdd10.;
format ID \$9. date yymmdd10.;
input ID date;
cards;
100030006 2015-10-06
100030006 2015-09-03
100030006 2015-08-19
;
run;

data Result;
set one;
day = day(date);
month = month(date);
year = year(date);
Desired_Result=catx(' ',day,month,year);
run;
proc print;
run;

🔒 This topic is solved and locked.