Help using Base SAS procedures

date format

Accepted Solution Solved
Reply
Super Contributor
Super Contributor
Posts: 444
Accepted Solution

date format

anyone familiar with ccyymmdd format?

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



Accepted Solutions
Solution
‎09-17-2014 09:21 PM
Super User
Super User
Posts: 7,076

Re: date format

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


All Replies
SAS Employee
Posts: 232

Re: date format

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

Super Contributor
Super Contributor
Posts: 444

Re: date format

Posted in reply to Community_Help

thanks admin

will take a  look shrtly

Super User
Posts: 11,343

Re: date format

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;

Super Contributor
Super Contributor
Posts: 444

Re: date format

so ccyy is actually the current  year,right?

Super User
Super User
Posts: 7,076

Re: date format

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

Super Contributor
Super Contributor
Posts: 444

Re: date format

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?

Solution
‎09-17-2014 09:21 PM
Super User
Super User
Posts: 7,076

Re: date format

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.

Super Contributor
Super Contributor
Posts: 444

Re: date format

Thanks Smiley Happy

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 8 replies
  • 799 views
  • 1 like
  • 4 in conversation