<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Summing one-way costs to create two-way travel costs in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Summing-one-way-costs-to-create-two-way-travel-costs/m-p/465777#M118811</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Year      (Month   Company   Origin   Destination) ($)  Cost;
cards;
2015     Jan        A5              CLE      CHI               0.05
2015     Jan        A5              CHI       CLE              0.1
2015     Jan        A6              COL      DCA             0.08
2015     Jan        A6              DCA      COL             0.11
;

data want;
if 0 then set have;
_cost=0;
do until(last.company);
set have;
by year month company;
_cost+cost;
end;
do _n_=1 by 1 until(last.company);
set have;
by year month company;
if _n_=1 then output;
end;
drop cost;
rename _cost=cost;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 29 May 2018 18:09:05 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2018-05-29T18:09:05Z</dc:date>
    <item>
      <title>Summing one-way costs to create two-way travel costs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summing-one-way-costs-to-create-two-way-travel-costs/m-p/465753#M118798</link>
      <description>&lt;P&gt;I have cost information that gives me the cost of transporting between locations, for example A and B, in both directions. For example, the cost of transportation from A to B is $.05 and the cost of transportation from B to A is $0.1. I would like to add these two costs, $0.05 and $0.1 to create round trip cost.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Year&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Month&amp;nbsp;&amp;nbsp; Company&amp;nbsp;&amp;nbsp; Origin&amp;nbsp;&amp;nbsp; Destination&amp;nbsp; Cost&lt;/P&gt;&lt;P&gt;2015&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Jan&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CLE&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CHI&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.05&lt;/P&gt;&lt;P&gt;2015&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Jan&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CHI&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CLE&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.1&lt;/P&gt;&lt;P&gt;2015&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Jan&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A6&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; COL&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DCA&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.08&lt;/P&gt;&lt;P&gt;2015&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Jan&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A6&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DCA&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; COL&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.11&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like it to be:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Year&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Month&amp;nbsp;&amp;nbsp; Company&amp;nbsp;&amp;nbsp; Origin&amp;nbsp;&amp;nbsp; Destination&amp;nbsp; Cost&lt;/P&gt;&lt;P&gt;2015&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Jan&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CLE&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CHI&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.15&lt;/P&gt;&lt;P&gt;2015&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Jan&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A6&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; COL&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DCA&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.19&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The data lists only routes (one-way) and average costs.&amp;nbsp; I have considered sql, merge, modify. I am not sure which one would give the output I want without mistakes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 May 2018 17:58:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summing-one-way-costs-to-create-two-way-travel-costs/m-p/465753#M118798</guid>
      <dc:creator>larusso522</dc:creator>
      <dc:date>2018-05-29T17:58:48Z</dc:date>
    </item>
    <item>
      <title>Re: Summing one-way costs to create two-way travel costs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summing-one-way-costs-to-create-two-way-travel-costs/m-p/465754#M118799</link>
      <description>&lt;P&gt;Ok, so what do you need help with?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/212586"&gt;@larusso522&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have cost information that gives me the cost of transporting between locations, for example A and B, in both directions. For example, the cost of transportation from A to B is $.05 and the cost of transportation from B to A is $0.1. I would like to add these two costs, $0.05 and $0.1 to create round trip cost.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 May 2018 16:39:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summing-one-way-costs-to-create-two-way-travel-costs/m-p/465754#M118799</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-05-29T16:39:00Z</dc:date>
    </item>
    <item>
      <title>Re: Summing one-way costs to create two-way travel costs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summing-one-way-costs-to-create-two-way-travel-costs/m-p/465768#M118804</link>
      <description>&lt;P&gt;How can I do that for 400000 rows of data that is listed by year, month, and company using SAS?&lt;/P&gt;</description>
      <pubDate>Tue, 29 May 2018 17:31:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summing-one-way-costs-to-create-two-way-travel-costs/m-p/465768#M118804</guid>
      <dc:creator>larusso522</dc:creator>
      <dc:date>2018-05-29T17:31:09Z</dc:date>
    </item>
    <item>
      <title>Re: Summing one-way costs to create two-way travel costs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summing-one-way-costs-to-create-two-way-travel-costs/m-p/465769#M118805</link>
      <description>&lt;P&gt;That depends on how your data is arranged. Without knowing that it's impossible to answer your question. It could be a lookup problem - which I suspect it is.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you provide some mocked up data that reflects your problem, with the desired results?&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;If you can provide sample data and anything you've tried so far, you'll get a lot more responses, faster responses and&amp;nbsp;code.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In general,&amp;nbsp;vague question = vague answer.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 May 2018 17:34:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summing-one-way-costs-to-create-two-way-travel-costs/m-p/465769#M118805</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-05-29T17:34:44Z</dc:date>
    </item>
    <item>
      <title>Re: Summing one-way costs to create two-way travel costs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summing-one-way-costs-to-create-two-way-travel-costs/m-p/465772#M118808</link>
      <description>&lt;P&gt;Is this setup a reasonable facsimile of the problem?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;* one way travel costs from point1 to point2;
data travel_cost;
   input point1:$1. point2:$1. cost;
datalines;
a b .05
a c .75
a d .3
a e 5
b a 1
b d 2
b e 4 
c a .56
c b 45
c d 1
c e 2
e a 1
e b .24
e c .01
e d 10
;
run;

* given an starting point and a destination point, what is round trip cost?;
* assume there can be multiple destinations;
* assume trip always ends with a return to start;
* assume trips for costing are presented in a string format;
* a trip from A to B will be presented as AB;
* a trip from A to B to E will be presented as ABE;
 
data trips_to_calculate;
	input trips $.;
datalines;
AB
ABE
EBC
BC
;
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;??&lt;/P&gt;</description>
      <pubDate>Tue, 29 May 2018 17:40:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summing-one-way-costs-to-create-two-way-travel-costs/m-p/465772#M118808</guid>
      <dc:creator>HB</dc:creator>
      <dc:date>2018-05-29T17:40:41Z</dc:date>
    </item>
    <item>
      <title>Re: Summing one-way costs to create two-way travel costs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summing-one-way-costs-to-create-two-way-travel-costs/m-p/465777#M118811</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Year      (Month   Company   Origin   Destination) ($)  Cost;
cards;
2015     Jan        A5              CLE      CHI               0.05
2015     Jan        A5              CHI       CLE              0.1
2015     Jan        A6              COL      DCA             0.08
2015     Jan        A6              DCA      COL             0.11
;

data want;
if 0 then set have;
_cost=0;
do until(last.company);
set have;
by year month company;
_cost+cost;
end;
do _n_=1 by 1 until(last.company);
set have;
by year month company;
if _n_=1 then output;
end;
drop cost;
rename _cost=cost;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 May 2018 18:09:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summing-one-way-costs-to-create-two-way-travel-costs/m-p/465777#M118811</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-05-29T18:09:05Z</dc:date>
    </item>
    <item>
      <title>Re: Summing one-way costs to create two-way travel costs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summing-one-way-costs-to-create-two-way-travel-costs/m-p/465779#M118813</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/212586"&gt;@larusso522&lt;/a&gt;&amp;nbsp;if every group are sets of two, consider merge have have(firstobs=2)&amp;nbsp; lookahead..There are tons of examples online and here. I am too lazy&lt;/P&gt;</description>
      <pubDate>Tue, 29 May 2018 18:10:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summing-one-way-costs-to-create-two-way-travel-costs/m-p/465779#M118813</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-05-29T18:10:44Z</dc:date>
    </item>
    <item>
      <title>Re: Summing one-way costs to create two-way travel costs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summing-one-way-costs-to-create-two-way-travel-costs/m-p/465783#M118815</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Year      (Month   Company   Origin   Destination) ($)  Cost;
cards;
2015     Jan        A5              CLE      CHI               0.05
2015     Jan        A5              CHI       CLE              0.1
2015     Jan        A6              COL      DCA             0.08
2015     Jan        A6              DCA      COL             0.11
;
data want;
set have have(in=b);
by year month company;
if first.company then do; _cost=0;_flag=0;end;
if not b then _cost+cost;
else if b then _flag+1;
if _flag=1;
drop cost _flag;
rename _cost=cost;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 May 2018 18:15:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summing-one-way-costs-to-create-two-way-travel-costs/m-p/465783#M118815</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-05-29T18:15:16Z</dc:date>
    </item>
    <item>
      <title>Re: Summing one-way costs to create two-way travel costs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summing-one-way-costs-to-create-two-way-travel-costs/m-p/465787#M118816</link>
      <description>&lt;P&gt;Get the round trip costs with:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data oneWayCosts;
input Year Month $ Company $ Origin $ Destination $ Cost;
datalines;
2015     Jan        A5              CLE      CHI               0.05
2015     Jan        A5              CHI       CLE              0.1
2015     Jan        A6              COL      DCA             0.08
2015     Jan        A6              DCA      COL             0.11
;

proc sql;
create table roundTripCosts as
select 
    a.year,
    a.month,
    a.company,
    a.origin,
    a.destination,
    a.cost + b.cost as roundTripCost
from
    oneWayCosts as a inner join
    oneWayCosts as b 
        on a.year=b.year and a.month=b.month and a.company=b.company and 
            a.origin=b.destination and a.destination=b.origin
where a.origin &amp;lt; a.destination;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 May 2018 18:24:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summing-one-way-costs-to-create-two-way-travel-costs/m-p/465787#M118816</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-05-29T18:24:11Z</dc:date>
    </item>
    <item>
      <title>Re: Summing one-way costs to create two-way travel costs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summing-one-way-costs-to-create-two-way-travel-costs/m-p/466004#M118882</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data oneWayCosts;
input Year Month $ Company $ Origin $ Destination $ Cost;
datalines;
2015     Jan        A5              CLE      CHI               0.05
2015     Jan        A5              CHI       CLE              0.1
2015     Jan        A6              COL      DCA             0.08
2015     Jan        A6              DCA      COL             0.11
;
data temp;
 set oneWayCosts;
 call sortc(Origin , Destination);
run;

proc sql;
select Year, Month, Company,Origin , Destination,sum(Cost) as Cost
 from temp
  group by Year, Month, Company,Origin , Destination;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 30 May 2018 13:38:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summing-one-way-costs-to-create-two-way-travel-costs/m-p/466004#M118882</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-05-30T13:38:22Z</dc:date>
    </item>
    <item>
      <title>Re: Summing one-way costs to create two-way travel costs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summing-one-way-costs-to-create-two-way-travel-costs/m-p/466011#M118883</link>
      <description>&lt;P&gt;HI can you make me understand&amp;nbsp; this please.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt; a&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;origin&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;b&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;destination and a&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;destination&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;b&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;origin
&lt;SPAN class="token statement"&gt;where&lt;/SPAN&gt; a&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;origin &lt;SPAN class="token operator"&gt;&amp;lt;&lt;/SPAN&gt; a&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;destination&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 May 2018 13:48:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summing-one-way-costs-to-create-two-way-travel-costs/m-p/466011#M118883</guid>
      <dc:creator>SJN</dc:creator>
      <dc:date>2018-05-30T13:48:41Z</dc:date>
    </item>
    <item>
      <title>Re: Summing one-way costs to create two-way travel costs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summing-one-way-costs-to-create-two-way-travel-costs/m-p/466248#M118944</link>
      <description>&lt;P&gt;The query joins two copies of the cost table. The records that are joined have the origin from the first copy equal to the destination of the second, and vice-versa. The a.origin &amp;lt; a.destination condition is to prevent two&amp;nbsp;instances of the same round trip&amp;nbsp;from appearing: O -&amp;gt; D -&amp;gt; O and D -&amp;gt; O -&amp;gt; D.&lt;/P&gt;</description>
      <pubDate>Wed, 30 May 2018 20:46:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summing-one-way-costs-to-create-two-way-travel-costs/m-p/466248#M118944</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-05-30T20:46:36Z</dc:date>
    </item>
    <item>
      <title>Re: Summing one-way costs to create two-way travel costs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summing-one-way-costs-to-create-two-way-travel-costs/m-p/467918#M119474</link>
      <description>&lt;P&gt;Do you know what happens if there are no matches? Does this program simply delete those?&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jun 2018 00:47:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summing-one-way-costs-to-create-two-way-travel-costs/m-p/467918#M119474</guid>
      <dc:creator>larusso522</dc:creator>
      <dc:date>2018-06-06T00:47:20Z</dc:date>
    </item>
    <item>
      <title>Re: Summing one-way costs to create two-way travel costs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summing-one-way-costs-to-create-two-way-travel-costs/m-p/467936#M119476</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/212586"&gt;@larusso522&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Do you know what happens if there are no matches? Does this program simply delete those?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;An inner join would delete any non matches. If you want everything from one table you can use a LEFT or RIGHT join.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jun 2018 02:56:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summing-one-way-costs-to-create-two-way-travel-costs/m-p/467936#M119476</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-06-06T02:56:54Z</dc:date>
    </item>
    <item>
      <title>Re: Summing one-way costs to create two-way travel costs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summing-one-way-costs-to-create-two-way-travel-costs/m-p/467938#M119477</link>
      <description>&lt;P&gt;Yes one-ways are omitted from the results. If you wanted to signal their absence, you could use a full join:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data oneWayCosts;
input Year Month $ Company $ Origin $ Destination $ Cost;
datalines;
2015     Jan        A5              CLE      CHI               0.05
2015     Jan        A5              CHI       CLE              0.1
2015     Jan        A6              COL      DCA             0.08
2015     Jan        A6              DCA      COL             0.11
2016     Jan        A6              DCA      COL             0.11
;

proc sql;
create table roundTripCosts as
select 
    coalesce(a.year, b.year) as year,
    coalesce(a.month, b.month) as month,
    coalesce(a.company, b.company) as company,
    coalesce(a.origin, b.destination) as origin,
    coalesce(a.destination, b.origin) as destination,
    a.cost + b.cost as roundTripCost
from
    oneWayCosts as a full join
    oneWayCosts as b 
        on a.year=b.year and a.month=b.month and a.company=b.company and 
            a.origin=b.destination and a.destination=b.origin
where calculated origin &amp;lt; calculated destination;
select * from roundTripCosts;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Jun 2018 03:05:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summing-one-way-costs-to-create-two-way-travel-costs/m-p/467938#M119477</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-06-06T03:05:20Z</dc:date>
    </item>
  </channel>
</rss>

