BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
psrajput
Obsidian | Level 7

Hi,

 

I have pulled out the date in this format:

DATE9.

 

And then was also able to convert into YYMMN.:

202006

 

But my ultimate goal is to get the following numeric date format:

20200600

 

That's how data is available.

 

Thanks in Advance.

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

Dates, by definition,cannot have a day of the month of 00.

 

So, you could add the zeros on the end via concatenating character strrings

 

want = cats(put(datevariable,yymmn6.),'00');

 

 

--
Paige Miller

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

Dates, by definition,cannot have a day of the month of 00.

 

So, you could add the zeros on the end via concatenating character strrings

 

want = cats(put(datevariable,yymmn6.),'00');

 

 

--
Paige Miller
ballardw
Super User

One way to create such a dangerous value is a custom format:

proc format;
picture dayzero (default=8)
low-high = '%Y%0m00' (datatype=date)
;
run;

data _null_;
   date = '05Jun2010'd;
   put date dayzero.;
run;

but I have a suspicion that you may be leaving something out.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

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.

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
  • 2 replies
  • 550 views
  • 5 likes
  • 3 in conversation