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 (September 2006, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 18 Sep 2006 13:36:02 +0000
Reply-To:     toby dunn <tobydunn@HOTMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         toby dunn <tobydunn@HOTMAIL.COM>
Subject:      Re: each line from each data set
Comments: To: davidlcassell@MSN.COM
In-Reply-To:  <BAY103-F38AA0CEA8FC5C22D2B1C0CB02D0@phx.gbl>
Content-Type: text/plain; format=flowed

David ,

I use to wonder about these things too, but it was keeping up at night so I stopped. ;-)

Toby Dunn

When everything is coming at you all at once, your in the wrong lane.

A truly happy person is someone who can smile and enjoy the scenery on a detour.

From: David L Cassell <davidlcassell@MSN.COM> Reply-To: David L Cassell <davidlcassell@MSN.COM> To: SAS-L@LISTSERV.UGA.EDU Subject: Re: each line from each data set Date: Sun, 17 Sep 2006 23:07:27 -0700

zhanglitt@YAHOO.COM wrote: > >I have two data sets that have the same variables. I >should create a new dataset whose first observation is >from data A, second observation from data B, third >from data A ... > >Can you tell me a way to do it? > >Thank you > >Li

You want to 'interleave' the two data sets.

If you have an ID variable which would match up across data sets and would change for each record, then you can do this with a single SET statement.

If not, you can create such a variable. I'll show you how, by building a data step view for both data sets and then interleaving them:

data A2 / view=A2; set A; recID = _n_; run;

data B2 / view=B2; set B; recID = _n_; run;

data all; set A2 B2; by recID; run;

Now let me ask you. Why do you want to do this? Normally, combining data sets should depend on data set keys which are already in the data files. This is fairly risky. A single lost record or record out of place will ruin your interleave.

HTH, David -- David L. Cassell mathematical statistician Design Pathways 3115 NW Norwood Pl. Corvallis OR 97330

_________________________________________________________________ Got something to buy, sell or swap? Try Windows Live Expo ttp://clk.atdmt.com/MSN/go/msnnkwex0010000001msn/direct/01/?href=http://expo.live.com/


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