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

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;

1 ACCEPTED SOLUTION

Accepted Solutions
SASKiwi
PROC Star

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.

View solution in original post

2 REPLIES 2
klappy711
Calcite | Level 5

The error occurs in the statement: fiscyear = input(charyear,year4.);

Is this because year4. is not an acceptable informat?

SASKiwi
PROC Star

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.

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!

How to Concatenate Values

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.

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
  • 2 replies
  • 6182 views
  • 1 like
  • 2 in conversation