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

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;

 

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

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.) ;

View solution in original post

2 REPLIES 2
Astounding
PROC Star

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.) ;

tobyfarms
Fluorite | Level 6
That Worked. Thanks for the quick fix.

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
  • 4324 views
  • 0 likes
  • 2 in conversation