<?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: Creating a to-from list from a vector in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-to-from-list-from-a-vector/m-p/631399#M187083</link>
    <description>&lt;P&gt;Perfect! Thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;. Tried it on the full dataset now (1.5 million rows), and after a ten-hour run, and subsequent NODUPKey run, I got it just as I wanted it! Brilliant!&lt;/P&gt;</description>
    <pubDate>Wed, 11 Mar 2020 22:06:15 GMT</pubDate>
    <dc:creator>ulricius</dc:creator>
    <dc:date>2020-03-11T22:06:15Z</dc:date>
    <item>
      <title>Creating a to-from list from a vector</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-to-from-list-from-a-vector/m-p/630612#M186697</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to create a list with the following principal confuguration,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;LineID;FromStopID;ToStopID
1;1;1&lt;BR /&gt;1;2;1
1;2;2
1;2;3
1;3;1
1;3;3
2;4;4
2;5;4
2;5;5
2;5;6
2;6;4
2;6;6&lt;/PRE&gt;&lt;P&gt;that is, a list of all possible pairwise combinations of entries from a dataset looking like this (the third column is what I regard as the "stopID vector"):&lt;/P&gt;&lt;PRE&gt;LineID;SequenceID;StopID
1;1;2
1;2;3
1;3;1
2;1;5
2;2;6
2;3;4&lt;/PRE&gt;&lt;P&gt;How should I proceed with the coding? As some of the combinations are missing in the inut table, they may me left out. The important requirement is that the code should only result in a list of those "ToStopID"s that follow after each "FromStopID" (=a higher sequenceID) in the input table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is a simplified version of a bigger issue, discussed at lenght in&lt;/P&gt;&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/Flaging-closest-match-per-row-by-referencing-data-from-external/m-p/627816" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/SAS-Programming/Flaging-closest-match-per-row-by-referencing-data-from-external/m-p/627816&lt;/A&gt; .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/Ulrik&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Mar 2020 12:55:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-to-from-list-from-a-vector/m-p/630612#M186697</guid>
      <dc:creator>ulricius</dc:creator>
      <dc:date>2020-03-09T12:55:47Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a to-from list from a vector</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-to-from-list-from-a-vector/m-p/630640#M186710</link>
      <description>&lt;P&gt;Can you explain the expansion for ID=1 in more detail ?&lt;/P&gt;</description>
      <pubDate>Mon, 09 Mar 2020 14:13:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-to-from-list-from-a-vector/m-p/630640#M186710</guid>
      <dc:creator>RichardDeVen</dc:creator>
      <dc:date>2020-03-09T14:13:21Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a to-from list from a vector</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-to-from-list-from-a-vector/m-p/630694#M186738</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/312891"&gt;@ulricius&lt;/a&gt;&amp;nbsp;wrote:
&lt;P class="1583775639762"&gt;(...)&lt;/P&gt;
&lt;P&gt;This is a simplified version of a bigger issue, discussed at lenght in&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/Flaging-closest-match-per-row-by-referencing-data-from-external/m-p/627816" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/SAS-Programming/Flaging-closest-match-per-row-by-referencing-data-from-external/m-p/627816&lt;/A&gt; .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/Ulrik&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/312891"&gt;@ulricius&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Without delving into that lengthy other thread I'd suggest this PROC SQL solution:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input LineID SequenceID StopID;
cards;
1 1 2
1 2 3
1 3 1
2 1 5
2 2 6
2 3 4
;

proc sql;
create table want as
select f.LineID, f.StopID as FromStopID, t.StopID as ToStopID
from have f, have t
where f.LineID=t.LineID &amp;amp; f.SequenceID&amp;lt;=t.SequenceID
order by 1,2,3;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 09 Mar 2020 17:44:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-to-from-list-from-a-vector/m-p/630694#M186738</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2020-03-09T17:44:11Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a to-from list from a vector</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-to-from-list-from-a-vector/m-p/631399#M187083</link>
      <description>&lt;P&gt;Perfect! Thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;. Tried it on the full dataset now (1.5 million rows), and after a ten-hour run, and subsequent NODUPKey run, I got it just as I wanted it! Brilliant!&lt;/P&gt;</description>
      <pubDate>Wed, 11 Mar 2020 22:06:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-to-from-list-from-a-vector/m-p/631399#M187083</guid>
      <dc:creator>ulricius</dc:creator>
      <dc:date>2020-03-11T22:06:15Z</dc:date>
    </item>
  </channel>
</rss>

