<?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: OD matrix (long form to a matrix form) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/OD-matrix-long-form-to-a-matrix-form/m-p/78185#M16937</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks! It works!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 17 Aug 2013 15:17:17 GMT</pubDate>
    <dc:creator>tesu</dc:creator>
    <dc:date>2013-08-17T15:17:17Z</dc:date>
    <item>
      <title>OD matrix (long form to a matrix form)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/OD-matrix-long-form-to-a-matrix-form/m-p/78183#M16935</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Suppose there are three districts: ag, du, and si. And the "count" variable indicates the number of people moving from a district from another district.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;origin destination count&lt;/P&gt;&lt;P&gt;ag ag 0&lt;/P&gt;&lt;P&gt;ag du 41&lt;/P&gt;&lt;P&gt;ag si 13&lt;/P&gt;&lt;P&gt;du ag 3&lt;/P&gt;&lt;P&gt;du du 0&lt;/P&gt;&lt;P&gt;du si 79&lt;/P&gt;&lt;P&gt;si ag 7&lt;/P&gt;&lt;P&gt;si du 6&lt;/P&gt;&lt;P&gt;si si 0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And I have to convert the above data to a matrix form as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;0 41 13 &lt;/P&gt;&lt;P&gt;3 0 79&lt;/P&gt;&lt;P&gt;7 6 0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How do I have to write the code to do that? Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Jul 2013 00:28:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/OD-matrix-long-form-to-a-matrix-form/m-p/78183#M16935</guid>
      <dc:creator>tesu</dc:creator>
      <dc:date>2013-07-15T00:28:03Z</dc:date>
    </item>
    <item>
      <title>Re: OD matrix (long form to a matrix form)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/OD-matrix-long-form-to-a-matrix-form/m-p/78184#M16936</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use transpose :&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data OD;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;input origin $ destination $ count;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;datalines;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;ag ag 0&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;ag du 41&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;ag si 13&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;du ag 3&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;du du 0&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;du si 79&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;si ag 7&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;si du 6&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;si si 0&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc sort data=OD; by origin destination; run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc transpose data=OD out=ODmat(drop=_NAME_);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;by origin;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;var count;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;id destination;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc print data=ODmat noobs; run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Jul 2013 00:55:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/OD-matrix-long-form-to-a-matrix-form/m-p/78184#M16936</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2013-07-15T00:55:17Z</dc:date>
    </item>
    <item>
      <title>Re: OD matrix (long form to a matrix form)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/OD-matrix-long-form-to-a-matrix-form/m-p/78185#M16937</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks! It works!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 17 Aug 2013 15:17:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/OD-matrix-long-form-to-a-matrix-form/m-p/78185#M16937</guid>
      <dc:creator>tesu</dc:creator>
      <dc:date>2013-08-17T15:17:17Z</dc:date>
    </item>
  </channel>
</rss>

