data t1;
input a b a1 a2 c a3;
cards;
1 2 3 4 5 6
6 5 4 3 2 1
;
run;
proc print data=t1;
run;
data b (drop=i);
set t1;
array a_t{*} a: ;
d=dim(a_t);
do i =1 to dim(a_t);
a_t{i}=a_t{i}+2/3;
end;
run;
proc print data=b width=min;
run;
Tuesday, April 17, 2012
use array to select partial data
In the following example, suppose we wanna add 2/3 for those variables whose name begin with 'a'. This iterative work is easy to be done with array. The trick is how to select the columns with name begin with 'a';
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment