Date: Mon, 24 Jul 2006 12:53:28 -0400
Reply-To: Doug Rohde <drohde01@COMCAST.NET>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Doug Rohde <drohde01@COMCAST.NET>
Subject: Re: SCL Questions (hijacked thread)
Joe,
It may be pointless the way you have implemented it, because the entire
thing resides within a bit of compiled code, datastep and all. What I
want to see is a bit of precompiled code then being called within a
datastep that is not part of the compiled code. Like this:
/*begin SCL code*/
init:
dcl num denom foo numer,
char(80) divide;;
divide='IF DENOM^=0 THEN FOO=NUMER/DENOM ;';
/*end SCL code*/
/*<compile...>*/
/*This is regular SAS code*/
data foo;
set foo;
/*do any random stuff here*/
÷ *the SCL divide function declared above;
/*do more random stuff here*/
run;
/*end regular SAS code*/
Can this be done?
Is this pointless? I don't think so. It's no less pointless than, say,
the SUM() or MAX() functions, which could just as well be implemented by
the user with IF..ELSE logic. It prevents against those times when you
say "Well, the denominator could NEVER be zero in this variable." It
saves keystrokes, which reduces the chances for typing errors. (or
forgetting to change variable names if you're copy/pasting)
In fact, I would say this is very similar to a wrapper class in your
favorite OO language, which abstracts the operations of tedious operations
like database access, for example, to save the time and effort of
programming it all a bunch of times. Sure, the scope is a lot smaller,
but it's the same idea.
Doug R
On Mon, 24 Jul 2006 12:00:54 -0400, Joe Whitehurst
<joewhitehurst@GMAIL.COM> wrote:
>Doug
>
>Let's assume Toby has read Kevin's mind correctly and Toby's example
>is in fact what Kevin had in mind. If I understand correctly, the
>example merely tests the denominator for a zero condition and performs
>the division only if the denominator is not zero. I think even those
>unfamiliar with SAS Component Language realize that the macro is
>pointless. It adds no functionality to a simple if statement:
>
>IF DENOM^=0 THEN FOO=NUMER/DENOM ;
>
>But for those literally minded folks who insist on seeing SCL code
>with the same functionality here is the equivalent pointless SCL code:
>
>init:
>dcl num denom foo numer,
> char(80) divide;;
>divide='IF DENOM^=0 THEN FOO=NUMER/DENOM ;';
>submit continue;
> data foo;
> set foo;
> ÷
> run;
>endsubmit;
>return;
>
>Even though pointless as regards functionality, it does serve the
>purpose of showing how much simpler even pointless code is than
>functionally equvalent Antiquated Macro Language.code.
>
>Joe Pointless
>
>On 7/24/06, toby dunn <tobydunn@hotmail.com> wrote:
>> Doug ,
>>
>> I think this is what Kevin had in mind:
>>
>> %Macro Divide( Numer = , Denom = ) ;
>>
>> %If ( &Denom = 0 ) %Then %Do ;
>> 0
>> %End ;
>> %Else %Do ;
>> %SysEvalF( &Numer / &Denom )
>> %End ;
>>
>> %Mend Divide ;
>>
>>
>>
>> Data Foo ;
>> Set Foo ;
>> Foo = Resolve( '%pdiv( Numer = ' || var1 || ' , Denom = ' || var2
|| ' ) ' )
>> ;
>> Run ;
>>
>>
>>
>>
|