Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Calculating Euclidean Distance


From   Anthony Laverty <anthonylav@googlemail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: Calculating Euclidean Distance
Date   Thu, 10 Jun 2010 10:08:04 +0100

Dear Statalist



I have data on patient numbers at various hospitals and am trying to
calculate a new variable which is the Euclidean distance between one
specific hospital (say A) and all of the others, so that i can select
which hospitals had the most similar number of patients across all
months.  The data is more or less arranged like this (although it has
a few more columns not of direct interest to this question):

Hospital     Time           Patients
A                 1                 456
A                 2                 759
A                 3                  236
B                 1                 214
B                 2                 854
B                 3                 325
C                 1                 250
C                  2                321
C                  3                852



So, i want to cycle through each time period and calculate the
difference squared between hospital A and all of the other hospitals
individually as one new variable.



Any suggestions greatly appreciated



Anthony Laverty

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index