Date: Fri, 16 Jan 1998 08:38:43 -0800
Reply-To: "kmself@ix.netcom.com" <kmself@ix.netcom.com>
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: "Karsten M. Self" <kmself@IX.NETCOM.COM>
Organization: Self Analysis
Subject: Re: Using array reference in a function
Content-Type: text/plain; charset="us-ascii"
On Wednesday, January 14, 1998 10:59 PM, Martin Trollope
[SMTP:MartinT@HOLLARD.CO.ZA] wrote:
> Don't have to state them all at all, can use
>
> min2 = min(of item{*});
>
>
> Martin Trollope. Martint@hollard.co.za
>
>
> ooooO Ooooo
> ( ) ( )
> \ ( ) /
> \__ ) (__ /
>
>
> >
> > data yy; set yy;
> > array item{10} col1-col10;
> > s=4;
> > min2 = min(of item{1}-item{s});
> >
>
> You have to explicitly state them all. I don't see how an array
> helps you in any case.
> min2=min(col1,col2,col3,col4,col5,col6,col7,col8,col9,col10);
>
> Roland Rashleigh-Berry
> mailto:roland.rashleigh-berry@virgin.net
Roland,
I hate to call you on this, but the three methods below produce identical
results, though 'list' and 'star' take considerably less CPU (not clearly
demonstrated with the small sample below). This is easily validated.
As for what advantage defining an array has -- for the MIN operation, not
much, but in general, arrays can be a powerful simplifying tool. In this
case, arrays use the least code, in an easily maintainable fashion.
73 data test;
74 array item{10};
75 do obs = 1 to 100;
76 do i = 1 to 10;
77 item{i} = ranuni(99999) * 20;
78 end;
79 output;
80 end;
81 drop i obs;
82 run;
NOTE: The data set WORK.TEST has 100 observations and 10 variables.
NOTE: The DATA statement used 0.25 seconds.
83
84 data list;
85 set test;
86 array item{*} item1-item10;
87 min = min(
88 item{1}, item{2}, item{3}, item{4}, item{5},
89 item{6}, item{7}, item{8}, item{9}, item{10}
90 );
91 run;
NOTE: The data set WORK.LIST has 100 observations and 11 variables.
NOTE: The DATA statement used 0.23 seconds.
92
93 data loop;
94 set test;
95 array item{*} item1 - item10;
96 do i= 1 to dim(item);
97 min= min( min, item{i});
98 end;
99 drop i;
100 run;
NOTE: The data set WORK.LOOP has 100 observations and 11 variables.
NOTE: The DATA statement used 0.2 seconds.
101
102 data star;
103 set test;
104 array item{*} item1 - item10;
105 min= min(of item{*});
106 run;
NOTE: The data set WORK.STAR has 100 observations and 11 variables.
NOTE: The DATA statement used 0.11 seconds.
107
108 proc compare data= list compare= loop noprint warning;
NOTE: The PROCEDURE COMPARE used 0.02 seconds.
109 proc compare data= list compare= star noprint warning;
110 run;
NOTE: The PROCEDURE COMPARE used 0.02 seconds.
Karsten M. Self (kmself@ix.netcom.com)
What part of "gestalt" don't you understand?
(Welchen Teil von "Gestalt" verstehen Sie nicht?)