BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
rakeshvvv
Quartz | Level 8

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

 

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

View solution in original post

4 REPLIES 4
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

AbhiD
Obsidian | Level 7

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;

Steelers_In_DC
Barite | Level 11

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;

Karansareen
Calcite | Level 5

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;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1023 views
  • 2 likes
  • 5 in conversation