Date: Thu, 30 Jun 2011 14:17:51 -0400
Reply-To: Arthur Tabachneck <art297@ROGERS.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Arthur Tabachneck <art297@ROGERS.COM>
Subject: Re: OT: Chance to Make SAS-L History: Did You Know That...
Content-Type: text/plain; charset=ISO-8859-1
Kumar,
Like Bob initially thought, I think it was a great tip as well. If Bob's
requirements were slightly different, the method could definitely make code
easier to maintain.
For example, if his situation called for the following:
Bob indicated that he has a complex data step that merges several other data
sets on a common BY variable (user_id). If he needed to guarantee that the
record existed in at least one key data set, instead of using:
data permdata;
merge ds1(in=a)
ds2(in=b)
ds3
ds4
ds5(in=c)
ds6(in=d);
by user_id;
if a or b or c or d;
run;
he could simplify the code as follows:
data permdata;
merge ds1(in=keepme)
ds2(in=keepme)
ds3
ds4
ds5(in=keepme)
ds6(in=keepme);
by user_id;
if keepme;
run;
HTH,
Art
--------
On Thu, 30 Jun 2011 08:16:14 -0500, SAS_learner <proccontents@GMAIL.COM>
wrote:
>hello soren ,
>
>This concept seems to be very interesting and little bit confusing , can
you
>please write back to us with a couple of examples please . I did not
>actually understood this technique in what way it can be used.
>
>thanks
>Kumar
>
>On Wed, Jun 29, 2011 at 2:31 AM, Søren Lassen <s.lassen@post.tele.dk>wrote:
>
>> You can use the same variable name in several IN= dataset options
>> in the same datastep?
>>
>> Example:
>> Data All_years;
>> set
>> xx98(in=y1998)
>> mylib.t1998(in=y1998)
>> otherdata
>> ;
>> if y1998 then year=1998;
>> else year=year(saledate);
>> run;
>>
>> The common IN= variable will be set if one or more of the datasets
>> are present, meaning that
>> Data out;
>> merge a b(in=inx) c(in=inx);
>> by ID;
>> if inx then...
>> is equivalent to
>> Data out;
>> merge a b(in=inb) c(in=inc);
>> by ID;
>> if inb or inc then...
>>
>> Regards,
>> S�ren
>>
|