Date: Tue, 27 Jan 2009 09:19:12 -0500
Reply-To: "Howard Schreier <hs AT dc-sug DOT org>"
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Howard Schreier <hs AT dc-sug DOT org>"
Subject: Re: Calculate the difference between values across all records
On Tue, 27 Jan 2009 01:35:07 -0800, Keith W. Larson
>Dear SAS list,
>I have some weather data for 145 locations across Europe. I would like to
calculate the difference between the mean annual temperature at each
location. I am not interested in a matrix, just three columns, Location_A,
Location_B, and Temp_Difference. I have included some sample code and what I
anticipate the output to look like.
>Thank you for your help once again.
>input location mean_temp;
>The results might look like this:
>Paris Paris 0
>Paris London 6
>Paris Stockholm 10
>London Paris 6
>London London 0
>London Stockholm 4
>Stockholm Paris 10
>Stockholm London 4
>Stockholm Stockholm 0
options formchar=' ';
select catx( ' '
,abs(a.mean_temp - b.mean_temp)
from test as a cross join test as b
order by a.mean_temp desc
, b.mean_temp desc
Paris Paris 0
Paris London 6
Paris Stockholm 10
London Paris 6
London London 0
London Stockholm 4
Stockholm Paris 10
Stockholm London 4
Stockholm Stockholm 0