Hi, I'm just trying to compare against certain columns from two datasets. One of these is derived from SQL database extraction and the other is a SAS dataset. The issue has been with the date variables. The 'rule_result_date' variable from the SAS dataset has an original format of ddmmmyy:hh:mm:ss, whilst the 'CDT' variable has a format of ddmmmyyyy from the SQL excel dataset. With the code below, I have managed to format the 'rule_result_variable' (which has been renamed as Date) into ddmmmyyyy. However the issue arises in the section when creating the final table 'Allign'. I am trying to compare both dates (i.e Date and CDT) by adding a new column 'Date_Equal' to show which dates are equal, denoted by either a '1' for equivalence or '0' for non-equivalence. However the 'Date_Equal' column is just returning all zeroes, despite the fact by visual observation I can see the dates are clearly equal. Would really appreciate some help on the matter. I have attached a screenshot of the 'Allign' table output to demonstrate the problem. Thank you. /* Import the SQL raw dataset */ proc import datafile= 'E:\SAS_BI\CFAD\AP\Data\Rules.xlsx' out= SIRA dbms= excel replace; run; /* SAS Dataset */ Data SAS_Extract; Set SIRA.SIRA_SCORES; policy_number_1 = substr(application_number,verify(application_number,'0')); date = datepart(rule_result_date); format date $DATE9.; run; data SIRA_NEW; set SIRA; date = input(CDT,DATETIME18.); run; proc sql; create table new as select distinct SE.policy_number_1, SE.rule_name, SE.date, SE.rule_result_key from SAS_Extract SE where date between '01JAN2014'D and '31MAR2014'D order by policy_number_1; run; proc sort data=SIRA_NEW nodupkey; by policy_number rule_name CDT; run; /* Merge both datasets using Proc SQL */ Proc sql; Create Table Allign as Select distinct N.policy_number_1, S.policy_number, N.rule_name as SAS_RN, S.rule_name as SIRA_RN, N.date, S.CDT, N.rule_result_key, S.match_Key, Case when S.rule_name = N.rule_name then 1 else 0 end as Rule_Equal, case when S.CDT = N.date then 1 else 0 end as Date_Equal From SIRA_NEW S inner join new N on S.policy_number = N.policy_number_1; run; Proc Freq DATA= Allign; Tables SAS_RN*Date_Equal; run;
... View more