分享一个社交网络关系分群的方法,如下:
数据集在最后
%macro rungroupi(id=);
%let length1 = 1;
%let length2 = 2;
proc sql noprint;
create table tmp_rlist as
select * from T_list_result where cser = &&clist&id.;
quit;
%do %until(&length1. = &length2.);
proc sql noprint;
create table tmp_clist as
select cser as tmp_cser from tmp_rlist
union all
select bcser as tmp_cser from tmp_rlist;
quit;
proc sql noprint;create table tmp_clist_2 as select distinct tmp_cser from tmp_clist;quit;/*set cser&bcser*/
proc sql noprint;select count(tmp_cser) as cnt into : length1 from tmp_clist_2;quit; /*set lenght1*/
/*renew tmp_rlist*/
proc sql noprint;
create table tmp_rlist as
select * from T_list_result where cser in (select tmp_cser from tmp_clist_2);
quit;
/*renew tmp_rlist*/
proc sql noprint;
create table tmp_clist as
select cser as tmp_cser from tmp_rlist
union all
select bcser as tmp_c