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

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

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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.

 

 

 

View solution in original post

6 REPLIES 6
Jagadishkatam
Amethyst | Level 16

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.

 

 

Thanks,
Jag
srinidhi
Fluorite | Level 6
Ok fine,
for example
name lunched new car year
BMW 2011-2012
Audi 2012-2013

it will be like this.
Jagadishkatam
Amethyst | Level 16
Thank you for your response. As discussed i am not sure if have a format to read yyyy-yyyy. Is it not fine if you keep the variable in character itself as you could see the years.
Thanks,
Jag
ballardw
Super User

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.

 

Tom
Super User Tom
Super User

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.

 

 

 

srinidhi
Fluorite | Level 6

Thanks Tom..Smiley Happy

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

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.

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
  • 6 replies
  • 2041 views
  • 3 likes
  • 4 in conversation