BookmarkSubscribeRSS Feed
ilmare
Calcite | Level 5


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!!

4 REPLIES 4
Haikuo
Onyx | Level 15

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

ilmare
Calcite | Level 5

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!!

Haikuo
Onyx | Level 15

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

ilmare
Calcite | Level 5

Hai.kuo,

Thank you for the info.

I didn't realze that there is a separate forum for SEG.

I really appreciate your help!!Smiley Happy

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 3408 views
  • 0 likes
  • 2 in conversation