Skip to content
Advertisement

Convert day of year to date using proc sql in SAS

I have a day of year column and need to convert it to a date.I want to find the exact date that the insurance coverage began for every person. I also have a year column

Have data:

Want data:

I searched up and find that the following command works in Oracle sql but does not work in SAS sql

I appreciate anyhelp

Advertisement

Answer

Looks like you just want to add START_DAY to the first day of the YEAR. You can use MDY() function to generate the first day of the year by using one for both the month and day numbers. Remember to subtract one day since the first day of the year is START_DAY number one and not number zero. Make sure to attach a date type format to it so it will print in a human readable way.

So if done in normal SAS code it might look like this:

The syntax in SQL is a little more confusing.

You can use any other date type format you want. You could even use the DDMMYY10. format to have the components of the dates displayed in the potentially confusing day,month,year order used in your example listing.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement