全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
1040 1
2012-02-14
小弟初学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;



二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2012-2-15 11:41:46
把set 变成merge 就行了
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群