I have a SAS dataset that has a variable, fiscyear, that are years, but are formatted as numeric. I'm trying to convert that variable to a YEAR4. format so that I can use the years as dates in a proc. The code I'm trying to use (shown below) is producing this error:
NOTE 485-185: Informat YEAR was not found or could not be loaded.
I don't understand why I get this error. Is there a different method I could be using? My code is shown below.
/* Convert fiscyear to date format */
data work.project_new (drop=fiscyear);
set WORK.project_old;
charyear = put(fiscyear,4.);
run;
data work.project_new (drop=charyear);
set work.project_new;
fiscyear = input(charyear,year4.);
format fiscyear year4.;
run;
You are trying to use YEAR as an INFORMAT, when it only exists in SAS as a FORMAT. This means it will only work when you already have a SAS date and you apply it with a PUT function or FORMAT statement.
Try this instead:
fiscyear = mdy(1, 1, input(charyear, 4.));
format fiscyear year4.;
To create a SAS date you also need to tell SAS the day and the month of your date, so that fiscyear actually stores 1 Jan 2014, for example.
The error occurs in the statement: fiscyear = input(charyear,year4.);
Is this because year4. is not an acceptable informat?
You are trying to use YEAR as an INFORMAT, when it only exists in SAS as a FORMAT. This means it will only work when you already have a SAS date and you apply it with a PUT function or FORMAT statement.
Try this instead:
fiscyear = mdy(1, 1, input(charyear, 4.));
format fiscyear year4.;
To create a SAS date you also need to tell SAS the day and the month of your date, so that fiscyear actually stores 1 Jan 2014, for example.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.