Date: Wed, 30 Apr 1997 17:14:20 -0500
Reply-To: kalfast <kalfast@PPRD.ABBOTT.COM>
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: kalfast <kalfast@PPRD.ABBOTT.COM>
Organization: Abbott Laboratories
Subject: Re: ***** I need help urgently ******
Content-Type: text/plain; charset=us-ascii
Tim Rogers wrote:
>
> I have a data set with 7,033 obs, the following is a sample data set:
>
> siteid agncyabr
> 1646 cd
> 1646 fsa
> 1646 nrcs
> 1972 fsa
> 1972 nrcs
> 1981 rd
> 1981 fsa
> 1990 rd
>
> I want to create a new variable called 'colocate'. If the the agncyabr
> has the same siteid as other agncyabr's, then I want the out put dataset
> to look like the following.
>
> siteid agncyabr colocate
> 1646 cd cd fsa nrcs
> 1646 fsa cd fsa nrcs
> 1646 nrcs cd fsa nrcs
> 1972 fsa fsa nrcs
> 1972 nrcs fsa nrcs
> 1981 rd fsa rd
> 1981 fsa fsa rd
> 1990 rd rd
>
> I appreciate any help, greatly.
> --
> ******************************************************************
> * Tim Rogers V-Mail: 703-689-0595 *
> * Associate Consultant Fax: 703-968-0595 *
> * Advantage Systems Group Inc. E-Mail: trogers@novarealty.com *
> * 1-800-484-5189 code 8077 trogers@patriot.net *
> ******************************************************************
Tim,
This should solve your problem:
proc sort data=<lib.>agncyabr out=agncyabr;
by siteid agncyabr;
run;
data colocate;
length colocate $80;
by siteid agncyabr;
retain colocate;
if first.siteid then colocate=agncyabr;
else colocate=trim(colocate)||' '||agncyabr;
if last.siteid then output;
run;
data <lib.><dataset_name>;
merge agncyabr colocate;
by siteid;
run;
HTH,
Tom
--
Thomas Kalfas, Consultant
Abbott Laboratories
E-mail: kalfast@pprd.abbott.com
Phone: (847) 938-8101
Fax: (847) 938-1736