小弟初学SAS,在工作中遇到一个问题。在两个数据组有一个共同的column,charged_party_number.如果两个数据里都有的话,那business_flag就变为1,其余都是0.以下是两种方法,第一个是用base 来编的,第二个是用proc sql来写的。但是问题是第一个所有的都business_flag都变成了0.而第二种方法一点问题也没有。我想知道第一种错在哪里。是不是因为我用了substr所以在Edm_Cust_profl table中的string 有空格?但是我也用了trim了呀。而且我也试过这样一个程序
就是
temp= '0'||substr(accs_num,3,9));
if temp=‘0423690008’ then test=''correct'';
结果显示correct
小弟语言表达能力不强,可能表达的是不是很清楚,但是真心求助,这里高手众多,希望能够帮忙找到答案。如果有什么看不懂的我会接下去解释的。谢谢!!!!!
proc sql;
create table Edm_Cust_profl as
select trim('0'||substr(accs_num,3,9)) as charged_party_number
from rocust.EDM_Cust_Profl
where Acct_Mgr_Typ_Cd in ('AM','TAM','BDM');
order by 1;
quit;
data cr_postpay2a;
set cr_postpay2a(in=a) Edm_Cust_profl (in=b);
by charged_party_number;
if a and b then business_flag=1;
else business_flag=0;
run;
----------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------
proc sql;
create table Edm_Cust_profl as
select accs_num
from rocust.EDM_Cust_Profl
where Acct_Mgr_Typ_Cd in ('AM','TAM','BDM');
order by 1;
quit;
proc sql;
update cr_postpay2a
set business_flag=1
where substr(cr_postpay2a.charged_party_number,2,9) in
(
select substr(accs_num,3,9) as accs_num
from EDM_Cust_Profl
)
;
quit;