I have date in proc report as : 20110812 but i would like to format it as 08-12-2011
What format do i need to use ?
I'm not well versed in proc report but, that said, the following works for me:
data have;
input name $ havedate;
cards;
John 20110811
Mary 20110812
;
options datestyle=ymd;
PROC REPORT NOWD DATA=have HEADLINE HEADSKIP CENTER MISSING;
COLUMNS NAME havedate date;
define havedate/display noprint;
define date/computed format=yymmddd10.;
COMPUTE date;
date=input(put(havedate,z8.),anydtdte.);
ENDCOMP;
RUN;
try mmddyy10.
mmddyy10. did not work.
I have the exact same question! Need to change 20110812 to be 08/12/2011. It's quite frustrating. I tried format mmddyy10. and format yymmdd10. Neither worked.
If the "date" is actually a character field, then you have to create a numeric field. In a datastep, that could be accomplished with:
data have;
input date $;
format wantdate mmddyyd10.;
wantdate=input(date,yymmdd8.);
cards;
20110812
;
To get a slash, rather than a hyphen, just change the d10 in the format to s10.
Mine is not character, it is in numeric format.
Mine is numeric as well
If it is the number 20110812, what happens if you try:
options datestyle=ymd;
data have;
input date;
format date mmddyyd10.;
date=input(put(date,z8.),anydtdte.);
cards;
20110812
;
This gives me sas date - 18850
That is one number off but, if you apply the format, you should get what you want. I ran:
options datestyle=ymd;
data have;
input date;
format date mmddyyd10.;
date=input(put(date,z8.),anydtdte.);
cards;
20110812
;
proc print;run;
and got:
Obs date
1 08-12-2011
Art,
You code work but for some reason when i apply it to my code it doesn't work. Here is my code. Am i missing anything ?
Options datastyle=ymd;
ods html file = 'path'
Proc Report ......
Column Date / Format=mmddyy10. group 'date' missing noprint;
compute before Date / Style=[just=l];
text1 = 'Date = ' || trim(left(input(put(date,z8.),anydtdte.)));
.....
I'm not well versed in proc report but, that said, the following works for me:
data have;
input name $ havedate;
cards;
John 20110811
Mary 20110812
;
options datestyle=ymd;
PROC REPORT NOWD DATA=have HEADLINE HEADSKIP CENTER MISSING;
COLUMNS NAME havedate date;
define havedate/display noprint;
define date/computed format=yymmddd10.;
COMPUTE date;
date=input(put(havedate,z8.),anydtdte.);
ENDCOMP;
RUN;
Thanks. It did work fo rme.
it should be works;
data test;input d $;
format dt mmddyyd10. st mmddyys10.;
dt=input(d,yymmdd8.);
st=dt;
cards;
20110812
;
run;
proc report nowd;
column d dt st;
define d/display;
define dt/display;
define st/display;
quit;
i had this wrong:
try the following:
data test ;
informat dval yymmdd8. ;
format dval yymmdd10. ;
input @1 dval ;
datalines ;
20110812
20110813
20110814
20110815
20110816
20110817
;
run ;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.