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 :
| 2 | 1988 |
| 3 | 1989 |
| 4 | 1990 |
| 5 | 1991 |
| 6 | 1992 |
| 7 | 1993 |
| 8 | 1994 |
| 9 | 1995 |
| 10 | 1996 |
| 11 | 1997 |
| 12 | 1998 |
| 13 | 1999 |
| 14 | 2000 |
| 15 | 2001 |
| 16 | 2002 |
| 17 | 2003 |
| 18 | 2004 |
| 19 | 2005 |
| 20 | 2006 |
| 21 | 2007 |
| 22 | 2008 |
| 23 | 2009 |
| 24 | 2010 |
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.
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.
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?
@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.
oh! of course...thank you 🙂
Your variable named YEAR is already displayed as a year, four digits, human readable. Do not format it.
Nearly 200 sessions are now available on demand with the SAS Innovate Digital Pass.
Explore Now →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.