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 (April 2009, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 14 Apr 2009 20:28:40 +0800
Reply-To:     Alex Murphy <goladin@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Alex Murphy <goladin@GMAIL.COM>
Subject:      Re: Data manipulation
Comments: To: "POHL, Dr., Stefan - AKTUARE" <pohl@aktuare.de>
In-Reply-To:  <260AAA9AD81945F7BD4447E28B9FFB53@aktuare.local>
Content-Type: text/plain; charset=ISO-8859-1

Hi,

I believe the solution for your problem is Cartesian product. Below is the code example.

data t; input Id1 x1 y1; datalines; 1 1 4 4 4 2 8 7 3 ; run;

data t2; input Id2 x2 y2; datalines; 1 1 4 4 4 2 8 7 3 ; run;

proc sql;

create table t3 as select * from t,t2;

quit;

On Tue, Apr 14, 2009 at 7:08 PM, POHL, Dr., Stefan - AKTUARE < pohl@aktuare.de> wrote:

> Hi, > > I want to build up a sequential distance matrix. id1 is the postal code, x1 > longitude and y1 lattitude. > > Id1 x1 y1 > 1 1 4 > 4 4 2 > 8 7 3 > > And I want to have this data: > > Id1 Id2 x1 y1 x2 y2 > 1 1 1 4 1 4 > 1 4 1 4 4 2 > 1 8 1 4 7 3 > ---------------------- > 4 1 4 2 1 4 > 4 4 4 2 4 2 > 4 8 4 2 7 3 > ---------------------- > 8 1 7 3 1 4 > 8 4 7 3 4 2 > 8 8 7 3 7 3 > > Now I can determine the distances between two postal codes. > > How can I manipulate my data? > > Stefan. > > ------------------------------ > *Von:* Alex Murphy [mailto:goladin@gmail.com] > *Gesendet:* Dienstag, 14. April 2009 13:03 > > *An:* POHL, Dr., Stefan - AKTUARE > *Cc:* SAS-L@listserv.uga.edu > *Betreff:* Re: Data manipulation > > Hi, > > Can I just check whether x2, y2 and id2 has any relations with the original > variables? > > On Tue, Apr 14, 2009 at 6:58 PM, POHL, Dr., Stefan - AKTUARE < > pohl@aktuare.de> wrote: > >> Hi, >> >> I need a more general solution. >> >> Suppose I have this data: >> >> Id1 x1 y1 >> 1 1 4 >> 4 4 2 >> 8 7 3 >> >> And I want to have this data: >> >> Id1 Id2 x1 y1 x2 y2 >> 1 1 1 4 1 4 >> 1 4 1 4 4 2 >> 1 8 1 4 7 3 >> 2 1 4 2 1 4 >> 2 4 4 2 4 2 >> 2 8 4 2 7 3 >> 3 1 7 3 1 4 >> 3 4 7 3 4 2 >> 3 8 7 3 7 3 >> >> Thank you for your help, Stefan. >> >> >> >> >> ------------------------------ >> *Von:* Alex Murphy [mailto:goladin@gmail.com] >> *Gesendet:* Dienstag, 14. April 2009 12:48 >> *An:* POHL, Dr., Stefan - AKTUARE >> *Cc:* SAS-L@listserv.uga.edu >> *Betreff:* Re: Data manipulation >> >> Hi, >> >> Try this. >> >> DATA T; >> SET T; >> >> DO I = 1 TO 3; >> >> ID2 = I; >> X2 = I; >> Y2 = I; >> >> OUTPUT; >> >> END; >> >> RUN; >> >> On Tue, Apr 14, 2009 at 6:10 PM, POHL, Dr., Stefan - AKTUARE < >> pohl@aktuare.de> wrote: >> >>> Hi, >>> >>> I have this data: >>> >>> Id1 x1 y1 >>> 1 1 1 >>> 2 2 2 >>> 3 3 3 >>> >>> I want to have this data: >>> >>> Id1 Id2 x1 y1 x2 y2 >>> 1 1 1 1 1 1 >>> 1 2 1 1 2 2 >>> 1 3 1 1 3 3 >>> 2 1 2 2 1 1 >>> 2 2 2 2 2 2 >>> 2 3 2 2 3 3 >>> 3 1 3 3 1 1 >>> 3 2 3 3 2 2 >>> 3 3 3 3 3 3 >>> >>> How can I do this? >>> >>> Thank you for help, Stefan. >>> >> >> >> >> -- >> Regards, >> Murphy Choy >> >> Certified Advanced Programmer for SAS V9 >> Certified Basic Programmer for SAS V9 >> DataShaping Certified SAS Professional >> >> > > > -- > Regards, > Murphy Choy > > Certified Advanced Programmer for SAS V9 > Certified Basic Programmer for SAS V9 > DataShaping Certified SAS Professional > >

-- Regards, Murphy Choy

Certified Advanced Programmer for SAS V9 Certified Basic Programmer for SAS V9 DataShaping Certified SAS Professional


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