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
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