LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (October 1997, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 28 Oct 1997 21:41:40 -0800
Reply-To:     Andrew James Llwellyn Cary <ajlcary@CARYCONSULTING.COM>
Sender:       "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From:         Andrew James Llwellyn Cary <ajlcary@CARYCONSULTING.COM>
Subject:      Re: merging data
Comments: To: Lars Ladfors <lars.ladfors@KK.OSTRA.SE>
Content-Type: text/plain; charset="us-ascii"

Here is one way using the SAS/BASE

PROC SUMMARY DATA=TWO NOPRINT NWAY; CLASS PGR; VAR PARITEL; OUTPUT OUT=MAX MAX=; PROC SORT DATA=MAX; BY PGR; PROC SORT DATA=ONE; BY PGR; DATA THREE; MERGE ONE MAX; BY PGR; RUN;

Here is another way using PROC SQL;

PROC SQL ; CREATE TABLE THREE AS SELECT *, PARITEL FROM ONE LEFT JOIN (SELECT PGR, MAX(PARITEL) as paritel from TWO GROUP BY PGR) AS T ON ONE.PGR=T.PGR; ;

On Tuesday, October 28, 1997 7:04 AM, Lars Ladfors[SMTP:lars.ladfors@KK.OSTRA.SE] wrote: >I have one dataset(data=enk.one) with 56 variables with 1500 >subjects(one >observation for one subject, each has a unique PNR); >I have a second dataset(data=enk.two) with 86 variables with the same >1500 subjects but in these dataset the same person could have 1, 2 or up >to six >observations.(there is totally 2782 observations in this set). > >The key-variable is PNR (a 10 digit number). > >In data=enk.two there is a variable called Paritet (a number between 0 >and 6); > > >I would like to ask data=enk.two what the highest number for variable >paritete is for each PNR > > > >This variable should be placed in data=enk.one > >For example; > >enk.one: >pnr=6789 >enk.two >pnr=6789 paritet=1 >pnr=6789 paritet=2 >pnr=6789 paritet=4 > > >then enk.one >pnr=6789 paritet=4 > > >How to do this? > >Your Sincerely > >Lars Ladfors > >

--------------------------------------- Andrew J. L. Cary Senior Curmudgeon Cary Consulting Services http://www.caryconsulting.com


Back to: Top of message | Previous page | Main SAS-L page