Hi,
I ve one data set in that the format is YYYY-YYYY, where this is called as reported year.
when i imported to sas studio & after i see it is takeing as Char insted of takeing as date and also i ve used the Code to covert
i.e, A= input(B,date9.) but still its not in yyyy-yyyy format. is there any other way to make sas to understand it is date format in yyyy-yyyy. can some help me on this to understand this one.
Thanks,
Srinidhi
YYYY-YYYY is not a date. You might think of it as a date range (or what Teradata calls a PERIOD), but SAS does not have a special data type for storing date ranges.
You are probably better off leaving it as a character variable.
You could possible store it as two variables, say start_year and end_year. But even then they wouldn't be dates, they would be just years.
Hi Srinidhi,
I do not think we have a format as yyyy-yyyy, which means there are 2 years concatenated to each other. if i think so. Since it is not a date format we cannot use any date format.
Could you please provide an example of the data you have to get better solution.
Before considering date formats you should ensure you understand how SAS values dates. Dates are the number of days since 1 January 1960, and always is a specific day. There are SAS supplied formats that display the pieces of data available such a year, month, month day and year in a variety of display formats, year and quarter, week of year, day of week and such.
Your value is not a "Date". It may be possible to create a custom format that would treat a single year value such as 2011 so that it would display as "2011-2012" but if you ever run into the "half year" model year for cars introduced at a later part of the annual cycly that approach may not work.
How will you use that "model year" value? Will you be doing anything like arithmetic or modeling? It may be better to just use the year introduced instead of 2 years.
YYYY-YYYY is not a date. You might think of it as a date range (or what Teradata calls a PERIOD), but SAS does not have a special data type for storing date ranges.
You are probably better off leaving it as a character variable.
You could possible store it as two variables, say start_year and end_year. But even then they wouldn't be dates, they would be just years.
Thanks Tom..
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 25. Read more here about why you should contribute and what is in it for you!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.