Date: Mon, 8 Jun 2009 09:15:30 -0500
Reply-To: "Data _null_;" <iebupdte@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Data _null_;" <iebupdte@GMAIL.COM>
Subject: Re: Identifying the source of an obs from concatenated files
In-Reply-To: <OFC079ECAB.741C66F9-ON852575CF.003D8C20-852575CF.003DC8EE@dom.com>
Content-Type: text/plain; charset=ISO-8859-1
I usually just create a string of 0,1s. If you want it to be like
_TYPE_ in PROC SUMMARY then reverse it. Convert it to decimal if you
want too. This should work with merge, where more than one IN
variable could be "true" for a given obs.
data id;
set sashelp.class(in=in1) sashelp.class(in=in2)
sashelp.class(in=in3);
length setID $3.;
setID=reverse(cats(of IN:));
setID2 = input(setid,binary.);
run;
proc freq;
tables setID:;
run;
On 6/8/09, Nat Wooding <Nathaniel.Wooding@dom.com> wrote:
> Joe
>
> I am concatenating sets so I would expect the source to be unique. Hence,
> only one of the In variables will be non-zero and there can be no mistake
> as to which set a particular obs came from.
>
> Nat
>
> Nat Wooding
> Environmental Specialist III
> Dominion, Environmental Biology
> 4111 Castlewood Rd
> Richmond, VA 23234
> Phone:804-271-5313, Fax: 804-271-2977
> Cel Phone: 804-205-0752
>
>
>
> Joe Matise
> <snoopy369@GMAIL.
> COM> To
> Sent by: "SAS(r) SAS-L@LISTSERV.UGA.EDU
> Discussion" cc
> <SAS-L@LISTSERV.U
> GA.EDU> Subject
> Re: Identifying the source of an
> obs from concatenated files
> 06/07/2009 08:31
> PM
>
>
> Please respond to
> Joe Matise
> <snoopy369@GMAIL.
> COM>
>
>
>
>
>
>
> I would suggest using powers of 2 rather than consecutive integers -
> otherwise you have problems like 'what does source=6 mean; is it 3,2,1 or
> 4,2?'
> so
> a (in=in1)
> b (in=in2)
> c (in=in4)
> d (in=in8)
> etc.
> Effectively identical to the function of the _TYPE_ variable in proc means
> output datasets.
> -Joe
>
> On Fri, Jun 5, 2009 at 3:47 PM, Nat Wooding
> <Nathaniel.Wooding@dom.com>wrote:
>
> > Let's say that we are concatenating a number of SAS data sets and we need
> > at some later point to identify the orgin of a observation. Using the In
> =
> > option in our set statement, we can write:
> >
> > Data New;
> > set
> > a (in = in1 )
> > b ( in = in2 )
> > c ( in = in3 ) ;
> > source = sum ( in1 , in2*2 , in3*3 );
> >
> > Now, for a given obs, source will take on the value of 1, 2, or 3 . To
> > fancy this up a bit, we could use a format to display the name of the
> > actual data set name. Where I use the construct "INn", you may use any
> > name that suites your fancy.
> >
> > Nat Wooding
> > Environmental Specialist III
> > Dominion, Environmental Biology
> > 4111 Castlewood Rd
> > Richmond, VA 23234
> > Phone:804-271-5313, Fax: 804-271-2977
> > Cel Phone: 804-205-0752
> >
> > CONFIDENTIALITY NOTICE: This electronic message contains
> > information which may be legally confidential and or privileged and
> > does not in any case represent a firm ENERGY COMMODITY bid or offer
> > relating thereto which binds the sender without an additional
> > express written confirmation to that effect. The information is
> > intended solely for the individual or entity named above and access
> > by anyone else is unauthorized. If you are not the intended
> > recipient, any disclosure, copying, distribution, or use of the
> > contents of this information is prohibited and may be unlawful. If
> > you have received this electronic transmission in error, please
> > reply immediately to the sender that you have received the message
> > in error, and delete it. Thank you.
> >
>
>
> CONFIDENTIALITY NOTICE: This electronic message contains
> information which may be legally confidential and or privileged and
> does not in any case represent a firm ENERGY COMMODITY bid or offer
> relating thereto which binds the sender without an additional
> express written confirmation to that effect. The information is
> intended solely for the individual or entity named above and access
> by anyone else is unauthorized. If you are not the intended
> recipient, any disclosure, copying, distribution, or use of the
> contents of this information is prohibited and may be unlawful. If
> you have received this electronic transmission in error, please
> reply immediately to the sender that you have received the message
> in error, and delete it. Thank you.
>
|