BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Toni2
Lapis Lazuli | Level 10

Hi, i would appreciate any help on this one 

 

i am trying to format the year variable in the format YYYY using the below. However, when i run it i get the below note and i am not sure how i can fix it? 

 

"NOTE 484-185: Format YYYY was not found or could not be loaded."

 

data ONS_y_pre;
set ONS_y_raw;
year1 = input(year,anydtdte32.);
format year1 yyyy4.;
run;

 

my data is :


Obs Year
21988
31989
41990
51991
61992
71993
81994
91995
101996
111997
121998
131999
142000
152001
162002
172003
182004
192005
202006
212007
222008
232009
242010

 

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

If you need to convert a 4-digit string to a SAS date, do not use the ANY.... informat.

In fact, I always advise strongly against using these informats.

See this short code example:

data test;
year = "2021";
year1 = mdy(1,1,input(year,4.));
format year1 year4.;
run;

You can find other interesting date formats here.

View solution in original post

6 REPLIES 6
Kurt_Bremser
Super User

If you need to convert a 4-digit string to a SAS date, do not use the ANY.... informat.

In fact, I always advise strongly against using these informats.

See this short code example:

data test;
year = "2021";
year1 = mdy(1,1,input(year,4.));
format year1 year4.;
run;

You can find other interesting date formats here.

Toni2
Lapis Lazuli | Level 10

thanks for the response. Since i am new here could you please expand a little bit the code to apply this for the years 1987 to 2000?

Kurt_Bremser
Super User

@Toni2 wrote:

thanks for the response. Since i am new here could you please expand a little bit the code to apply this for the years 1987 to 2000?


Just use my function call and FORMAT statement in your original code.

 

Toni2
Lapis Lazuli | Level 10

oh! of course...thank you 🙂

PaigeMiller
Diamond | Level 26

Your variable named YEAR is already displayed as a year, four digits, human readable. Do not format it.

--
Paige Miller
Toni2
Lapis Lazuli | Level 10
thanks for your response. The solution from @Kurt_Bremser worked for me

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 6 replies
  • 2800 views
  • 1 like
  • 3 in conversation