Date: Mon, 27 Oct 2008 10:25:49 -0400
Reply-To: Kevin Viel <citam.sasl@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Kevin Viel <citam.sasl@GMAIL.COM>
Subject: Re: Array Frustration!!!!
On Sat, 25 Oct 2008 17:46:08 -0400, Lewis Jordan <lewjord@UGA.EDU> wrote:
>My mistake. In the original posting, I had
>"data two;set one;..." I did not intend to refernce the "one" data set.
Below is the code the Howard sent, and works like a charm.
>
>Thanks for the help.
>
>data one;
>array knots{5};
> do i=1 to 5;
> knots{i}=ranuni(38211);
> call symput (compress('fyknot'||i),trim(left(knot{i})));
> end;
>drop i;
>run;
>
>data two;
>array x{5};
> do i=1 to 5;
> x{i}= symget( cats( 'fyknot' , i ) ) ;
> end;
>output;
>run;quit;
Not too many of us would consider this method. It looks like you are
trying to initialize x1-x5. Why bother with the macro facility at all?
For instance, if you are assigning x1-x5 using a Do-Loop, why not do it
directly and dispense with the SYMGET() call? Further, why even *have* the
array KNOT in the first dataset? The RANUNI() call can simply be the
second argument to the CALL SYMPUT() routine. Also, for your chance to
test benchmarks, consider: put( ranuni(38211) , 8.6 -L ), versus the two
functions (and the implicit conversion) that you have. If you describe your
goal or situation, we might be able to offer a sound set of solutions....
Lastly, consider another way to initialize (or, for kicks, stew over Paul
Dorfman's masterful use of CALL POKE() in the archives):
data _null_ ;
array one ( 4 ) ( 1 2 3 4 ) ;
put one1= ;
run ;
HTH,
Kevin
|