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.
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.
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.