Please bear with me as I try to get my problem across as clearly as possible.
I am trying to merge two variables, but I am getting an error that says "Invalid numeric data, DateLastContact='06/30/2005' , at line 1036 column 4." This message repeats for multiple observations.
I am importing an excel file which has two date columns. SAS reads one of the columns as numeric, the other as character (DateLastContact). I have tried to change DateLastContact into numeric in both SAS and excel and it's still coming back with an Invalid numeric data error when I try to merge. Here is my code:
PROC IMPORT DATAFILE = "C:\Users\bennetde\Documents\SAS\BCcombined3.xls"
DBMS = XLS OUT = SASBC REPLACE;
RUN;
proc contents data = SASBC OUT = Check;
RUN;
PROC PRINT DATA = Check;
RUN;
PROC CONTENTS returns:
DateLastContact $ 30 0 $ 30
DateLastFollowup_ContactOrDeath MMDDYY 10 0 0
So I tried in SAS:
DATA SASBC;
SET SASBC;
char_DateLastContact = input(DateLastContact, MMDDYY10.);
RUN;
But it did not work. I have also tried: "char_DateLastContact = input(DateLastContact, 12.);
Here is my code:
PROC IMPORT DATAFILE = "C:\Users\bennetde\Documents\SAS\BCcombined3.xls"
DBMS = XLS OUT = SASBC REPLACE;
RUN;
DATA SASBC;
SET SASBC;
drop DateLastContact DateLastFollowup_years;
if DateLastContact = . then char_DateLastContact =
put(DateLastFollowup_years, 20.);
else char_DateLastContact = DateLastContact;
RUN;
proc print data = SASBC;
RUN;
Here is a sample of the error message after trying to change the variable from numeric to character:
1008 DATA SASBC;
1009 SET SASBC;
1010 char_DateLastContact = input(DateLastContact, MMDDYY10.);
1011 format DateLastContact;
1012 RUN;
NOTE: Invalid argument to function INPUT at line 1010 column 24.
(I can't give you the lines after this unless I change patient info, but
this error message repeats for several observations.)
And here is the original error:
NOTE: Invalid numeric data, DateLastContact='09/21/2007' , at line 968
column 4
Any help would be appreciated.