Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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

st: Calculating Euclidean Distance

From   Anthony Laverty <>
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:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index