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 (February 2009, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Mon, 2 Feb 2009 07:03:46 -0500
Reply-To:   Nathaniel.Wooding@DOM.COM
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Nat Wooding <Nathaniel.Wooding@DOM.COM>
Subject:   Re: Combining 3 datasets into a file row by row one after the other
Comments:   To: karma <dorjetarap@GOOGLEMAIL.COM>
In-Reply-To:   <d6a0d8f10902020305s51f6e3c2u50bb908f6081a6fe@mail.gmail.com>
Content-Type:   text/plain; charset="US-ASCII"

Chumba

While I agree with Karma that the solution to this problem is to " interleave" the two data sets using a set and by statement, his/her I don't like the examples offered. Please take a look at the following code which shows what to do if you already have three SAS data sets.

Data one; input var; cards; 123 456 Data two; input var; cards; 112233 445566 Data three; input var; cards; 111222333 444555666 run;

** add a line counter to each data set; Data one; set one; line = _n_; run; Data two; set two; line = _n_; run;

Data three ; set three ; line = _n_; run;

* now interleave the three files using a set and by statement;

Data Final; set one two three; by line;

run;

Proc Print; run;

Nat Wooding Environmental Specialist III Dominion, Environmental Biology 4111 Castlewood Rd Richmond, VA 23234 Phone:804-271-5313, Fax: 804-271-2977

karma <dorjetarap@GOOGL EMAIL.COM> To Sent by: "SAS(r) SAS-L@LISTSERV.UGA.EDU Discussion" cc <SAS-L@LISTSERV.U GA.EDU> Subject Re: Combining 3 datasets into a file row by row one after the 02/02/2009 06:05 other AM

Please respond to karma <dorjetarap@GOOGL EMAIL.COM>

You can use set and by statements to interleve the data.

HTH

data one; input num @@; cards; 1 4 ; data two; input num @@; cards; 2 5 ; data three; input num @@; cards; 3 6 ; data combined; set one two three; by num; run; proc print;run;

2009/2/2 chumba <vikas.dharamsattu@gmail.com>: > Hey All, > > I need to combine 3 datasets into a file row by row such that first > observation from the first dataset > precedes the first row of the second dataset which inturn precedes the > first row of the third dataset and so on. > > ie. > > table1 NEW > DATASET > obs num > obs1 ------------------------------------> 1 > obs1 (table1) > obs2 > obs3 > obs4 > obs5 > > table2 > > obs1 -------------------------------------> 2 > obs1 (table2) > obs2 > obs3 > obs4 > obs5 > > table3 > > obs1 -----------------------------------------> 3 > obs1 (table3) > obs2 > obs3 > obs4 > obs5 4 > obs2 (table1) > 5 > obs2 (table2) > 6 > obs2 (table3) > > .......and so on........... > > > Can anyone please help me out on this. > > Thanks, > Vikas >

CONFIDENTIALITY NOTICE: This electronic message contains information which may be legally confidential and or privileged and does not in any case represent a firm ENERGY COMMODITY bid or offer relating thereto which binds the sender without an additional express written confirmation to that effect. The information is intended solely for the individual or entity named above and access by anyone else is unauthorized. If you are not the intended recipient, any disclosure, copying, distribution, or use of the contents of this information is prohibited and may be unlawful. If you have received this electronic transmission in error, please reply immediately to the sender that you have received the message in error, and delete it. Thank you.


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