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

anyone familiar with ccyymmdd format?

I am supposed to convert today's date using the above format but not working


1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Yes. 'CCYYMMDD' is NOT a SAS FORMAT.  It is someone's idea of a mnemonic way of describing the way that they want the date to display.

View solution in original post

8 REPLIES 8
Community_Help
SAS Employee

Hi.. I moved your quesiton to the Procedures community so more people will see your question. I also did a search on ccyymmdd and found a few threads with answers. Does this one help? https://communities.sas.com/message/132225#132225

Tal
Pyrite | Level 9 Tal
Pyrite | Level 9

thanks admin

will take a  look shrtly

ballardw
Super User

In SAS if you have a date variable then the equivalent format is yymmddN8.

The CC or century will show up with most SAS formats when the field is wide enough to provide  a 4 digit year.

In a data step:

data want;

     x=today();

     format x yymmddN8. ;

run;

proc print; run;

Tal
Pyrite | Level 9 Tal
Pyrite | Level 9

so ccyy is actually the current  year,right?

Tom
Super User Tom
Super User

CCYY is notation for a four digit year CC is the century (currently 21) and YY are the last two digits of the year.

If you want today's date then use the DATE() function.  (You can also call the same function using the name TODAY() instead).

This will return the current date as the number days since beginning of 1960.  You can then use the PUT() function to apply a FORMAT to the value to convert that into the 8 digit string that you want.  If you want that string of digits converted to a number you can use an INPUT() function.

data _null_;

  today=date();

  today_str = put(today,yymmddn8.);

  today_num = input(today_str,8.);

  put today=

     / today=  date9.

     / today_str=

     / today_str= $quote.

     / today_num=

     / today_num = comma10.

;

run;

today=19983

today=17SEP2014

today_str=20140917

today_str="20140917"

today_num=20140917

today_num=20,140,917

Tal
Pyrite | Level 9 Tal
Pyrite | Level 9

Im actually supposed to show today's date using this format ccyymmdd so if y=today() after trying format y ccyymmdd. I was not getting anything. So I should do  format y yymmdd8. then?

Tom
Super User Tom
Super User

Yes. 'CCYYMMDD' is NOT a SAS FORMAT.  It is someone's idea of a mnemonic way of describing the way that they want the date to display.

Tal
Pyrite | Level 9 Tal
Pyrite | Level 9

Thanks Smiley Happy

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 8 replies
  • 3637 views
  • 1 like
  • 4 in conversation