- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
anyone familiar with ccyymmdd format?
I am supposed to convert today's date using the above format but not working
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
thanks admin
will take a look shrtly
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
so ccyy is actually the current year,right?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks