Hi All,
The following code creates the table #movecluster only if a.cluster_cnt + b.cluster_cnt <= 1000.
How do we create another table say #thresh when a.cluster_cnt + b.cluster_cnt >1000 and then write to SAS dataset.
We need to_id,from_id,a..cluster_cnt,b..cluster_cnt in the SAS dataset.
There are 400 mil records being processed.
%local rowcnt i;
%do i = 1 %to 90;
%let rowcnt = 0;
execute (
select to_id, min(from_id) from_id
into #movecluster
from (
select min(a.to_id) as to_id, a.from_id
from (
select a.cust_cluster_id to_id
,b.cust_cluster_id from_id
from proc_custs_clust_work a join vise_share a1 on a.cust_xref_id = a1.cust_xref_id
join vise_share b1 on b1.cluster_id = a1.cluster_id
join proc_custs_clust_work b on b.cust_xref_id = b1.cust_xref_id
and a.cluster_cnt + b.cluster_cnt <= 1000
where a.cust_cluster_id < b.cust_cluster_id
group by a.cust_cluster_id, b.cust_cluster_id
) a
group by a.from_id
) b
group by to_id
) by sybase;