Hi I have a question in my code;
I have date values in character format;
Exp: Date 2015-09-25
I need to convert the date into 2015/09/25 which is in character format.
My code:
date1=input(date,yymmdd10.);
format date yymmdds10.;
But the code resulted in value numeric format. I need the value in chracter format. 2015/09/25. Please help.
Thank you
date = translate(date,"/","-");
There is actually two instances where you might want character dates - ISO dates for instance are character. The other is for display purposes, most times put to format is fine, but sometimes you may want additional information for report purposes.
But I totally agree with you, unless there is a very good reason there is no reason to not use numeric date or time variables as they are far easier to use. I suspect he is trying to put these in macro list or something similar (in which case don't).
You can use the inverse of INPUT, PUT:
date2=put(date1, yymmdds10.);
I refrain from disputing your expressed need for this. I think it is out of order until you have been asked questions on the matter, which has not happened. And I won't.
Hope this helps,
-Jan.
Hi all,,
Thank you very much. Both codes are working for me as I am validating a dataset using proc compare. Thank yoiu.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.