I have a date field that is defined as character(MMDDYYCC).
Example: 11301220(Novermber 30th, 2012)
Could anyone please help me to convert this to CCYYMMDD in Numeric value?
The result should look like this: 20121130.
The reason why I need this in Numeric value is to sort this data.
Thank you for your help in advance!!
Try this:
data have;
input date$12.;
date1=input(cats(substr(date,1,4),substr(date,7,2),substr(date,5,2)),mmddyy10.);
format date1 yymmddn8.;
cards;
11301220
12011221
;
proc print;run;
Haikuo
Hi Haikuo,
Thank you very much for the prompt response. I really appreciate it.
The thing is I'm completely new to SAS Enterprise Guide pr SAS and I was trying to use your code in the "Computed Columns" like this:
input(cats(substr(date,1,4),substr(date,7,2),substr(date,5,2)),mmddyy10.):
format date yymmddn8.:
And it gave me an error.
Would it be possible for you to tell me how I can do this in the Enterprise Guide screen?
Thank you very much!!
sorry. I am among those old school SAS programmers who are NOT the targeting populations of EG. I have never used EG myself even I know it has been installed on my pc. I am sure someone on the forum with EG experience will surely come to rescue.
On a side note, if you have posted your question on EG board, I would probably have never responded.
Good Luck,
Haikuo
Hai.kuo,
Thank you for the info.
I didn't realze that there is a separate forum for SEG.
I really appreciate your help!!
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.