Hello,
I am importing several tables where the date field is in Character format(1994/06/17), which I want to place is date9 format (17JUN1994). I know the fix is simple but I am missing something in my code. .
1 %_eg_hidenotesandsource;
5 %_eg_hidenotesandsource;
28
29
30 Data work.Weather_Merge;
31 set ACY_F_100117_2017_10_02_07_30_21 DCA_F_100117_2017_10_02_07_30_27 ILG_F_100217_2017_10_03_07_30_37
31 ! SBY_F_100217_2017_10_03_07_30_42;
32 where 'O/F'n = 'O';
33
34 rename 'O/F'n = Status;
35 hour=substr('Forecast Date'n,11,3);
36 date=substr('Forecast Date'n,1,10);
37
38 format date date9.;
______
484
NOTE 484-185: Format $DATE was not found or could not be loaded.
39
40 Drop 'Forecast Date'n 'Forecast Date_0001'n;
41 Run;
NOTE: There were 98 observations read from the data set WORK.ACY_F_100117_2017_10_02_07_30_21.
WHERE 'O/F'n='O';
NOTE: There were 98 observations read from the data set WORK.DCA_F_100117_2017_10_02_07_30_27.
WHERE 'O/F'n='O';
NOTE: There were 98 observations read from the data set WORK.ILG_F_100217_2017_10_03_07_30_37.
WHERE 'O/F'n='O';
NOTE: There were 98 observations read from the data set WORK.SBY_F_100217_2017_10_03_07_30_42.
WHERE 'O/F'n='O';
NOTE: The data set WORK.WEATHER_MERGE has 392 observations and 15 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds
Data work.Weather_Merge;
set ACY_F_100117_2017_10_02_07_30_21 DCA_F_100117_2017_10_02_07_30_27 ILG_F_100217_2017_10_03_07_30_37 SBY_F_100217_2017_10_03_07_30_42;
where 'O/F'n = 'O';
rename 'O/F'n = Status;
hour=substr('Forecast Date'n,11,3);
date=substr('Forecast Date'n,1,10);
format date date9.;
Drop 'Forecast Date'n 'Forecast Date_0001'n;
Run;
You are creating DATE as a character variable. But to apply the DATE9 format, DATE must be numeric, with a value that matches SAS's idea of what a date looks like. Fortunately, all of this can be corrected by changing this statement:
date=substr('Forecast Date'n,1,10);
Instead, it should be:
date=input('Forecast Date'n, yymmdd10.) ;
You are creating DATE as a character variable. But to apply the DATE9 format, DATE must be numeric, with a value that matches SAS's idea of what a date looks like. Fortunately, all of this can be corrected by changing this statement:
date=substr('Forecast Date'n,1,10);
Instead, it should be:
date=input('Forecast Date'n, yymmdd10.) ;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.