SAS BASE&SAS EM 关联分析的学习 proc dmdb and proc assoc

本来想用其他的软件对数据做关联分析的,但公司不许安装其他的软件,只有SAS BASE SAS EG SAS EM。

没办法,只能用现有的软件。

1.SAS EM

   1.1打开EM 软件,将数据导入EM 中,导入数据前将数据先整理一下,两个变量,一个客户号,一个是客户买的产             品。

    1.2 点击左边选项框 的 流程图 ,然后把 原数据 图标和 关联 图标,用线连接起来。角色 要选择 事务,两个变量的对象应该选择 目标变量(产品) 和 ID(客户号)。选择好后,点击关联 图标中的开始,数据就可以运行了。

     1.3 数据的结果出来后,看看组合之间的情况。支持度 置信度 LIFT 提升度 什么左边 右边的情况。

2.SAS BASE

   2.1 这个要写代码了,其实代码也很简单了,有procedure sentence 嘛

   2.2 上代码,人大论坛一哥们写的,我就不写了,要注意到地方我提醒一下。

         proc dmdb  proc assoc 这两个句子后面必须使用同样的数据集,不然运行会报错了。

         

data test;
  input id $ 1 class1 $ 3 class2 $ 5 class3 $ 7 class4 $ 9 class5 $ 11 class6 $ 13 class7 $ 15 ;
cards;
1 0 0 1 1 0 1 0
2 1 0 0 1 0 1 1
3 0 1 1 0 1 1 0
4 1 1 0 1 0 1 1
5 0 1 1 1 0 1 0
6 0 0 0 1 0 1 1
;
run;

data items2;
set test;
length tid 8;
length item $8;
tid = _n_;
item = class1;
output;
item = class2;
output;
item = class3;
output;
item = class4;
output;
item = class5;
output;
item = class6;
output;
item = class7;
output;
keep tid item;
run;
proc sql;
alter table items2
modify item char(8);
quit;
proc dmdb data=items2 dmdbcat=dbcat;
class tid item;
run; quit;
proc assoc data=items2 dmdbcat=dbcat pctsup=0.5out=frequentItems;
id tid;
target item;
run;
proc rulegen in=frequentItems dmdbcat=dbcat out=rules minconf=80;
run ;
proc sort data=rules;
by descending conf;
run ;
data surviverules;
set rules(where=(set_size>1));
run;
proc print data=surviverules;
var conf support lift rule ;
run ;

  • 1
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值