Procedure Freq use less CPU and memory.
1215 options fullstimer;
1216
1217 data t1;
1218 do i=1 to 1e7;
1219 cat=ceil(ranuni(123)*10);
1220 output;
1221 end;
1222 run;
NOTE: The data set WORK.T1 has 10000000 observations and 2 variables.
NOTE: DATA statement used (Total process time):
real time 1.88 seconds
user cpu time 0.92 seconds
system cpu time 0.34 seconds
Memory 177k
OS Memory 7024k
Timestamp 6/26/2011 9:56:31 PM
1223
1224 proc freq data=t1;
1225 table cat;
1226 run;
NOTE: There were 10000000 observations read from the data set WORK.T1.
NOTE: PROCEDURE FREQ used (Total process time):
real time 1.07 seconds
user cpu time 0.76 seconds
system cpu time 0.14 seconds
Memory 168k
OS Memory 7024k
Timestamp 6/26/2011 9:56:32 PM
1227
1228 proc iml;
NOTE: IML Ready
1229 use t1;
1230 read all var {cat};
1231 close t1;
1232 t0=time();
1233 *freq start here;
1234 categories = unique(cat);
1235 count = j(ncol(categories), 1, 0);
1236 do i = 1 to ncol(categories);
1237 idx = loc(cat = categories[i]);
1238 count[i] = ncol(idx);
1239 end;
1240 print count;
1241 *end here;
1242 time=time()-t0;
1243 print time;
1244 quit;
NOTE: Exiting IML.
NOTE: 22 workspace compresses.
NOTE: PROCEDURE IML used (Total process time):
real time 3.54 seconds
user cpu time 3.07 seconds
system cpu time 0.45 seconds
Memory 172405k
OS Memory 179180k
Timestamp 6/26/2011 9:56:35 PM