Help with the limit of Proc Summary in creating combination

Accepted Solution Solved
Reply
Super Contributor
Posts: 371
Accepted Solution

Help with the limit of Proc Summary in creating combination

Hi Everyone,

I am using proc summary to create all combination of a list of variables.

For a list of 36 variables each has one value, Proc Summary can do WAYS 4 in about 2-3 minutes and WAYS 5 takes forever.

SAS doesn't use much resource at all since the RAM and CPU usage doesn't show any significant increase.

I wonder if there is anyway to improve the Proc summary or there is better method to use.

Any suggestion is very much appreciated.

HHC

data cond1;
length name $10;
input name $ value;

datalines;
a -1
b -1
c 3
d -1
e -1.5
f 5
g 0
h 3
i 1
k -2
l 1
m 1
n 1
o 7
p 1
q 2
x -2
y 2
z 1
aa 2
dd1 1
cc 1
dd 1
gg -1.5
tt 3
yy -2
uu -2
ii 1
oo -1.5
pp 1
ll 1
kk 2
jj 3
mm 1
zz 1
zzz 2
;;run;

proc transpose data=cond1 out=cond;
id name; run;

proc summary data=cond ;
   class _all_;
   ways 4;
   output out=combo;
   run;


Accepted Solutions
Solution
‎02-01-2014 10:08 PM
Respected Advisor
Posts: 4,649

Re: Help with the limit of Proc Summary in creating combination

This is faster:

 

%let k=5;

%let N=36;

data combo2;

set cond;

array _v{*} _NUMERIC_;

array _vv{&N} _temporary_;

array _k{&k} _temporary_;

do i = 1 to &N;

       _vv{i} = _v{i};

       end;

do _i = 1 to comb(&N, &k);

       call allcombi(&N, &k, of _k{*});

       call missing(of _v{*});

       do _j = 1 to &k;

            _v{_k{_j}} = _vv{_k{_j}};

            end;

       output;

       end;

drop _i _j _name_;

run;

 

PG

PG

View solution in original post


All Replies
Solution
‎02-01-2014 10:08 PM
Respected Advisor
Posts: 4,649

Re: Help with the limit of Proc Summary in creating combination

This is faster:

 

%let k=5;

%let N=36;

data combo2;

set cond;

array _v{*} _NUMERIC_;

array _vv{&N} _temporary_;

array _k{&k} _temporary_;

do i = 1 to &N;

       _vv{i} = _v{i};

       end;

do _i = 1 to comb(&N, &k);

       call allcombi(&N, &k, of _k{*});

       call missing(of _v{*});

       do _j = 1 to &k;

            _v{_k{_j}} = _vv{_k{_j}};

            end;

       output;

       end;

drop _i _j _name_;

run;

 

PG

PG
Super Contributor
Posts: 371

Re: Help with the limit of Proc Summary in creating combination

Hi PG,

That code is awesome and I will try to understand it.

I start with proc summary "without WAYS option" to get all combination (1 factor to N factor).

Then SAS cannot go beyond 5. That's why I think of doing ways 1 ways 2 ... Then get stuck at ways 5.

Your code force SAS to utilize the PC capacity!!!

Thank you very much,

HHC

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 178 views
  • 0 likes
  • 2 in conversation