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
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.
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.
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;
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;
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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.
Ready to level-up your skills? Choose your own adventure.