BookmarkSubscribeRSS Feed
Paul_de_Barros
Obsidian | Level 7
The reason this post (Tom on 3/1/2013 at 2:41pm) finally cleared it up for me is that I realized that the functions MONTH, DAY, and YEAR were returning numeric values, which would automatically lack any leading zeroes, regardless of the formatting applied to the date they were extracting from.
damanaulakh88
Obsidian | Level 7

Hi Omega,

Please find below the code and its output for you problem:-

Code:-

=================================================

data new;

informat mydate mmddyy10.;

input mydate ;

format mydate mmddyy10.;

datalines;

03/04/2013

11/03/2012

04/11/2012

01/01/2011

05/09/2009

;

run;

data new1(drop= month day year);

set new;

month=month(mydate);

day=day(mydate);

year=year(mydate);

new_date=cats(month,"/",day,"/",year);

run;

===============================================

Output:-

================================================

Obs        mydate    new_date

1     03/04/2013    3/4/2013

2     11/03/2012    11/3/2012

3     04/11/2012    4/11/2012

4     01/01/2011    1/1/2011

5     05/09/2009    5/9/2009

==================================================

/Daman

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
  • 16 replies
  • 7534 views
  • 9 likes
  • 9 in conversation