YYYYMMDD Format in SAS + Other SAS Date Formats
yyyymmdd sas,yyyymmdd format in sas,sas mdy,mdy sas,sas date format yyyymmdd,sas date format yyyymm ,sas yyyymmdd format,sas date yyyymmdd,sas format date yyyymmdd,sas yyyymm,sas format yyyymm
Top Udemy SAS Course Pick:
YYYYMMDD format is one of the more common date formats in SAS. Date Formats, in general, help you display dates how you prefer in your output. It is common for people to confuse formats and informats. The former controls how your output is displayed, while the latter helps you read particular dates into SAS.
So let’s look at a scenario.
If you want to display a date in this form:
You can use the YYYYMMDD Format.
How would you accomplish this?
First, it is important to realize that the default separator or delimiter is a dash or hyphen for this particular format. The date we are using as an example does not have a dash or hyphen as a separator, instead it is a slash. The slash is one of the other possible separators you can use. Here are the others:
n no separator
Since in our example we are using a slash, the code below is how you would code it.
format nameofvar yymmdds10.; (notice the extra s..the s represents the slash separator)
The 10 represents the width of the output field. If you count how many characters make up that date format, you will notice that it is 10. (including the two separators).
This is a very common date format as well that will let you write date values in these forms:
ddmmmyy, ddmmmyyyy, or dd-mmm-yyyy.
The default width of the output field is 7, and the range is 5 to 11.
If you are in a situation where you read your date in as a character and you want to continue to use that same variable name, you need to output the result as character. For example:
nameofvar = put (input(nameofvar, mmddyy10.), yymmdds10. );
If you are confused by this syntax, please check out my article on the put and input functions (link to it below) , and if you still have questions, please ask me on here!