Sas 连接大桌子

Sas 连接大桌子,sas,Sas,我必须在SAS中执行以下逻辑: If the product field in Client_lookup table is ‘DC’ and if the client_nbr field in Client_lookup table matches with the client_nbr column in Gforce_Auth table, then the first six digits of merchant_number field in Gf

我必须在SAS中执行以下逻辑:

If 
    the product field in Client_lookup table is ‘DC’  
    and if the client_nbr field in Client_lookup table matches with the client_nbr column in  Gforce_Auth table, 
then 
    the first six digits of merchant_number field in Gforce_Auth tables will be compared with the first six digit of current_account_number in the  Gforce_Auth tables.

If it becomes equal, then the In store column = ‘Y’ otherwise it is set to ‘N’. The in store column will be set to null if the client _nbr field is not same in both the tables.
请让我知道如何连接这两个表,并在连接时检查上述条件

我尝试使用merge语句,但没有成功。提前谢谢

问候,,
苏迪尔

我相信以下几点应该对你有用。有更有效的方法可以做到这一点,但我认为这个例子应该更容易遵循

proc sort data=Client_lookup;
   by client_nbr;
proc sort data=Gforce_Auth;
   by client_nbr;
run;

data New_File;
   merge client_lookup(in=in_client_lookup where=(product = 'DC'))
         Gforce_Auth  (in=in_gforce_auth);
   by client_nbr;
   format in_store $1.;
   format merchant_nbr6 cur_acct_nbr6 $6.;
   if in_client_lookup and in_gforce_auth then do;
      merchant_nbr6 = substr(left(merchant_number),1,6);
      cur_acct_nbr6 = substr(left(current_account_nbr),1,6);
      if (merchant_nbr6 eq cur_acct_nbr) then in_store = 'Y';
      else in_store = 'N';
   end;
   else do;
      in_store = ' ';
   end;
   drop merchant_nbr6 cur_acct_nbr6;
run

您使用了什么代码来尝试合并?请发布输入数据的示例以及所需的结果。每个表中有多少行?