- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;