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