Tuesday, December 15, 2009

Automatic index variable _i_ in DO OVER

Recently SAS-L started an new topic "Do over can't be nested?".
I think it is very helpful for anyone who is interested with DO OVER.

quote:
Paul Choate says:
A little history lesson - in the 5.18 manual page 44 chapter 4 it says: "You can process more than one array in a DO OVER group if the arrays have the same number of elements and the same index variable."

It later says: "... (DO OVER) arrays use the automatic index variable _I_."
unquote


* Sample code;
data _null_;
array arra a1-a10 (0 1 2 3 4 5 6 7 8 9);
array arrb b1-b10 (10 11 12 13 14 15 16 17 18 19);

_i_=3;
put _i_= arra= arrb=;

_i_=6;
put _i_= arra= arrb=;

do over arra;
put "Start: " _i_=; * _i_ will be initialized to 1;
do over arrb;
put _i_= arra= arrb=;
end;
put "End: " _i_=; * ;
end;
run;

Thursday, December 3, 2009

RUN-group processing in SAS/Graph procedures

In SAS packages, some procedures may support RUN-group processing, e.g. Proc CATALOG, Proc DATASETS in SAS/Base, Proc GPLOT, Proc GCHART in SAS/Graph and Proc REG in SAS/STAT, etc.

Basically, RUN-group processing is used to perform task interactivly and efficiently without restarting the procedure. It is very intersting that ONLY the ones in SAS/Graph can reset or cancel global and local statements, BY statements, WHERE statement.

* Sample Code;
proc sort data=sashelp.class out=class;
by name;
run;
proc gplot data=class;
where;
by;
title "All Subjects";
plot height*weight;
run;
where sex='M';
by name;
title "Male";
plot height*weight;
run;
where sex='F';
by;
title "Female";
plot height*weight;
run;
quit;

For more information, please read SAS/GRAPH Processing: RUN-Group Processing.