Date: Tue, 22 Mar 2011 13:10:20 +0800
Reply-To: Clark An <kuhasu@126.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Clark An <kuhasu@126.COM>
Subject: Re: How to use the elements of an array to be the param of the
macro code
Content-Type: text/plain; charset=GBK
Dear toby,
It's not for bussiness,so there is no one specific object actually.
As you can see, the problems always be out after some have been solved.
This way I have found if can work,is the fastest way for that,all just because there is no such a function.
And I also know there are lots of sas users want to realize the expression computation,
so the discussion should be multi-win.
And as far as I know, it seems simple,but not easy actually.So it seems only old birds can reply.
At 2011-03-22 12:35:17£¬"toby dunn" <tobydunn@hotmail.com> wrote:
Seems everytime someone comes up with a solution you dismiss it because you have a new requirement
you didn't state the requirement up front. Which is probably why many have stopped answering your posts.
We do this for free not because your paying us. The better your question is written the faster you will get a
solution that will meet your requirements.
So let me help you out.... Stop.... really think about all your very very very specific requirements first.
Then list them all out with a very detailed explainantion of what your are starting with and what you
wish to end up with.
Toby Dunn
"I'm a hell bent 100% Texan til I die"
"Don't touch my Willie, I don't know you that well"
> Date: Tue, 22 Mar 2011 12:19:34 +0800
> From: kuhasu@126.com
> To: tobydunn@hotmail.com; sas-l@listserv.uga.edu
> Subject: Re:RE: How to use the elements of an array to be the param of the macro code
>
> Thank you so much!
>
> But the array sel must be an array in the same data step which means put+%include file can not work.
> And for the param in the macro :List1 = %Str(6,5,7,9,10,12,14,8,2,1,3,4) ,657910121482134 need to be an array,
> And it seems %str(arrayname[*]) can not work too.
>
> And I just relized although the sample code is simple but not easy actually.So is it necessary to reopen a topic to attract more old birds?
>
> Thank you and cheers!
>
> At 2011-03-22 12:04:05£¬"toby dunn" <tobydunn@hotmail.com> wrote:
> Thanks for the better example of what you want it really does help.
> This whole thing still seems like it would be better worked out using data sets and a %Include,
> which is way more SAS like than forcing it through a Macro.
>
> Not sure if I have it correct as I am still unsure the rule governing the reverse order through
> the List1. This may be what you intended or perhaps just happen stance given the data supplied.
> Either way your gonna have to make sure what ever rule you use is well documented.
>
>
>
> %Macro FN( List1 = , List2= ) ;
> %Local I K Start ;
>
> %Let Start = %Sysfunc( CountC( %SuperQ(List1) , %Str(,) ) ) ;
>
> %Do I = %Eval(&Start+1) %To 1 %By -1 ;
> %Let K = %Scan( %SuperQ( List1 ) , &I , %Str(,) ) ;
> Fn&I = %Scan( %SuperQ( List2 ) , &K , | ) ;
> %End ;
> %Mend FN ;
>
>
> Data A ;
> %FN( List1 = %Str(6,5,7,9,10,12,14,8,2,1,3,4) ,
> List2 = %Str(2|exp(fn12)|5|12|(fn3*fn4)|exp(fn2)|(fn5-fn6)|4|sum(fn7,fn8)|sum(fn9,fn10)|7|log(fn11)|9|3|6) )
> Output ;
> Run ;
>
>
> Toby Dunn
>
>
> "I'm a hell bent 100% Texan til I die"
>
> "Don't touch my Willie, I don't know you that well"
>
>
>
>
> > Date: Mon, 21 Mar 2011 23:11:08 -0400
> > From: kuhasu@126.COM
> > Subject: Re: How to use the elements of an array to be the param of the macro code
> > To: SAS-L@LISTSERV.UGA.EDU
> >
> > Thank you guys~
> > And I think I need to reclarify my question:
> >
> > %macro a;
> > data a;
> > array sel[12] (6,5,7,9,10,12,14,8,2,1,3,4);
> > /*array fn[12] fn1-fn12;*/
> > %let c=1;
> > %let cd=2|exp(&fn12)|5|12|(fn3*fn4)|exp(&fn2)|(fn5-fn6)|4|sum(fn7,fn8)|sum
> > (fn9,fn10)|7|log(&fn11)|9|3|6;
> >
> > %let fn1=%SCAN(&cd,6,|);
> > %let fn2=%SCAN(&cd,5,|);
> > %let fn3=%SCAN(&cd,7,|);
> > %let fn4=%SCAN(&cd,9,|);
> > %let fn5=%SCAN(&cd,10,|);
> > %let fn6=%SCAN(&cd,12,|);
> > %let fn7=%SCAN(&cd,14,|);
> > %let fn8=%SCAN(&cd,8,|);
> > %let fn9=%SCAN(&cd,2,|);
> > %let fn10=%SCAN(&cd,1,|);
> > %let fn11=%SCAN(&cd,3,|);
> > %let fn12=%SCAN(&cd,4,|);
> > fn12=&fn12.;
> > fn11=&fn11.;
> > fn10=&fn10.;
> > fn9=&fn9.;
> > fn8=&fn8.;
> > fn7=&fn7.;
> > fn6=&fn6.;
> > fn5=&fn5.;
> > fn4=&fn4.;
> > fn3=&fn3.;
> > fn2=&fn2.;
> > fn1=&fn1.;
> > run;
> > %mend;
> > %a;
> >
> > And sorry for the non plan text email,no important info in them.
> > Cheers!
>
>
|