Date: Mon, 14 Jul 2003 17:21:48 -0400
Reply-To: Howard Schreier <Howard_Schreier@ITA.DOC.GOV>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Howard Schreier <Howard_Schreier@ITA.DOC.GOV>
Subject: Re: simple data set merge/appending ??
I suggest a couple of SQL views to set things up:
proc sql;
create view both as
select * from First
union
select * from Second
order by ID, year;
create view shell as select * from
(select distinct ID from both),
(select distinct year from both)
order by ID, year;
quit;
Then just a simple UPDATE to get the desired output:
data with_missing;
update shell both;
by ID year;
run;
On Mon, 14 Jul 2003 13:34:38 -0700, JM Doyle <doylejm@JMU.EDU> wrote:
>Hi,
>I want to append/merge two data sets that look like this:
>
>First data set is:
>
>ID YEAR XVAR
>1 2001 10
>2 2001 16
>
>Second data set is:
>
>ID YEAR XVAR
>1 2002 11
>2 2002 17
>3 2002 19
>
>I want the combined data to allow for a missing obs. for ID=3 in 2001 like
this:
>
>ID YEAR XVAR
>1 2001 10
>1 2002 11
>2 2001 16
>2 2002 17
>3 2001 .
>3 2002 19
>
>With a merge or a set command, I don't get the missing observation in 2001
for ID=3.
>
>Any help would be appreciated. Thank you