Assuming that day of Birth might be not accurate in left hand table (as I got less records than expected) I decided to join both tables just by month and by year. I got the below log however. Does it mean I wrongly combine datepart and month/year function? Is there any syntax mistake? It does work properly when I use datepart function alone on the left like that:
Datepart(B.date_of_birth)=A.MEM_BIRTH_DT
After I included month /year like the following it stopped working properly:
52 datepart(month(B.date_of_birth))=month(A.MEM_BIRTH_DT) AND
53 datepart(YEAR(B.date_of_birth))=YEAR(A.MEM_BIRTH_DT)
************************************************************
log:
PROC SQL;
45 !
46 CREATE TABLE OUT.FOUND_HEALTH2 AS
47 (select distinct A.*, b.startdate, b.enddate, b.date_of_birth
48 FROM OUT.bc65_strangers_not_in2003 B, OUT.RGSTR_key_real A
49 WHERE b.MEMBER_LAST_NAME= a.MEM_LAST_NAME AND
50 b.MEMBER_FIRST_NAME= a.MEM_FIRST_NAME AND
51 B.sex=a.MEM_gender AND
52 datepart(month(B.date_of_birth))=month(A.MEM_BIRTH_DT) AND
53 datepart(YEAR(B.date_of_birth))=YEAR(A.MEM_BIRTH_DT)
54 );
INFO: Data set OUT.BC65_STRANGERS_NOT_IN2003.DATA is in a foreign host format. Cross Environment Data Access will be used, which
may require additional CPU resources and reduce performance.
NOTE: Invalid argument to function MONTH. Missing values may be generated.
NOTE: Invalid arguments to the DATEPART function have caused the function to return a missing value.
NOTE: Invalid argument to function YEAR. Missing values may be generated.
NOTE: Invalid arguments to the DATEPART function have caused the function to return a missing value.
NOTE: Invalid arguments to the MONTH function have caused the function to return a missing value.
NOTE: Invalid arguments to the YEAR function have caused the function to return a missing value.
NOTE: Table OUT.FOUND_HEALTH2 created, with 0 rows and 11 columns.
What I am doing wrong
Irin
--------------------------------------------------------------------------------
Datepart(B.date_of_birth)=A.MEM_BIRTH_DT
After I included month /year like the following it stopped working properly:
52 datepart(month(B.date_of_birth))=month(A.MEM_BIRTH_DT) AND
53 datepart(YEAR(B.date_of_birth))=YEAR(A.MEM_BIRTH_DT)
************************************************************
log:
PROC SQL;
45 !
46 CREATE TABLE OUT.FOUND_HEALTH2 AS
47 (select distinct A.*, b.startdate, b.enddate, b.date_of_birth
48 FROM OUT.bc65_strangers_not_in2003 B, OUT.RGSTR_key_real A
49 WHERE b.MEMBER_LAST_NAME= a.MEM_LAST_NAME AND
50 b.MEMBER_FIRST_NAME= a.MEM_FIRST_NAME AND
51 B.sex=a.MEM_gender AND
52 datepart(month(B.date_of_birth))=month(A.MEM_BIRTH_DT) AND
53 datepart(YEAR(B.date_of_birth))=YEAR(A.MEM_BIRTH_DT)
54 );
INFO: Data set OUT.BC65_STRANGERS_NOT_IN2003.DATA is in a foreign host format. Cross Environment Data Access will be used, which
may require additional CPU resources and reduce performance.
NOTE: Invalid argument to function MONTH. Missing values may be generated.
NOTE: Invalid arguments to the DATEPART function have caused the function to return a missing value.
NOTE: Invalid argument to function YEAR. Missing values may be generated.
NOTE: Invalid arguments to the DATEPART function have caused the function to return a missing value.
NOTE: Invalid arguments to the MONTH function have caused the function to return a missing value.
NOTE: Invalid arguments to the YEAR function have caused the function to return a missing value.
NOTE: Table OUT.FOUND_HEALTH2 created, with 0 rows and 11 columns.
What I am doing wrong
Irin
--------------------------------------------------------------------------------