Hi,
I am having trouble switching dates that look like this '28MAY1927:00:00:00' to '05/28/1927'. Does anyone know how to do this?
Thanks.
use anydtdte. format for reading date and once you read apply date9. format.
Please try below one...
data want;
input date anydtdte.;
format date date9.;
cards;
28MAY1927:00:00:00
;
run;
One correction use date10. instead of date9.
Yesd KarlK you are right.. Thanks...
Tushar, I think you meant mmddyy10. format, no? The OP wants "05/28/1927", not "28MAY1927".
Karl
Hi,
Cant we use datepart(date_time) and then use format on that?
Thanks
Hi Guys,
Thanks for the help. One more question, what if it is a column I am using in a sas data table?
Thanks.
Suppose if its the sas dataset where on one variable you wanted to apply this format then you can use Proc dataset procedure with modify statement.
Make a format.
proc format; picture x low-high='%0m/%0d/%Y'(datatype=datetime) ; run; data want; input date datetime20.; x=date; format date datetime20. x x10.; cards; 28MAY1927:00:00:00 ; run;
Ksharp
Hi Ksharp,
I have read the picture format after you have posted the solution and did not clearly understand it..
x x10.; means u are applying a format named x10. on the variable x
what is the meaning of '%0m/%0d/%Y' ?????
why did you put x x10. ???? just x x. would not be enough???
Thanks
Plz check documentation firstly .
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.