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

sas-innovate-2024.png

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.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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