<?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: random access to variables in observations in Mathematical Optimization, Discrete-Event Simulation, and OR</title>
    <link>https://communities.sas.com/t5/Mathematical-Optimization/random-access-to-variables-in-observations/m-p/433228#M2190</link>
    <description>&lt;P&gt;And here's another approach that uses PROC OPTGRAPH:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data names(keep=node source);
   set bipartite(rename=(name=node));
   source = 1;
run;
proc optgraph links=bipartite data_nodes_sub=names;
   links_var from=Name to=CommitteeAssignment;
   shortpath out_weights=outdata(rename=(source=rep1 sink=rep2) where=(rep1 &amp;lt; rep2 and path_weight=2));
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 01 Feb 2018 18:56:20 GMT</pubDate>
    <dc:creator>RobPratt</dc:creator>
    <dc:date>2018-02-01T18:56:20Z</dc:date>
    <item>
      <title>random access to variables in observations</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/random-access-to-variables-in-observations/m-p/433131#M2185</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've playing around with Proc OptGraph recently.&amp;nbsp; I have a data set consisting of district representatives in CA and the committees that they serve on.&amp;nbsp; Here are the first 10 observations sorted by committee assignment.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Obs&amp;nbsp;&amp;nbsp; &amp;nbsp;District&amp;nbsp;&amp;nbsp; &amp;nbsp;Name&amp;nbsp;&amp;nbsp; &amp;nbsp;Committee Assignment&lt;BR /&gt;1&amp;nbsp;&amp;nbsp; &amp;nbsp;16th&amp;nbsp;&amp;nbsp; &amp;nbsp;Costa, Jim&amp;nbsp;&amp;nbsp; &amp;nbsp;Agriculture&lt;BR /&gt;2&amp;nbsp;&amp;nbsp; &amp;nbsp;10th&amp;nbsp;&amp;nbsp; &amp;nbsp;Denham, Jeff&amp;nbsp;&amp;nbsp; &amp;nbsp;Agriculture&lt;BR /&gt;3&amp;nbsp;&amp;nbsp; &amp;nbsp;1st&amp;nbsp;&amp;nbsp; &amp;nbsp;LaMalfa, Doug&amp;nbsp;&amp;nbsp; &amp;nbsp;Agriculture&lt;BR /&gt;4&amp;nbsp;&amp;nbsp; &amp;nbsp;20th&amp;nbsp;&amp;nbsp; &amp;nbsp;Panetta, Jimmy&amp;nbsp;&amp;nbsp; &amp;nbsp;Agriculture&lt;BR /&gt;5&amp;nbsp;&amp;nbsp; &amp;nbsp;31st&amp;nbsp;&amp;nbsp; &amp;nbsp;Aguilar, Pete&amp;nbsp;&amp;nbsp; &amp;nbsp;Appropriations&lt;BR /&gt;6&amp;nbsp;&amp;nbsp; &amp;nbsp;42nd&amp;nbsp;&amp;nbsp; &amp;nbsp;Calvert, Ken&amp;nbsp;&amp;nbsp; &amp;nbsp;Appropriations&lt;BR /&gt;7&amp;nbsp;&amp;nbsp; &amp;nbsp;13th&amp;nbsp;&amp;nbsp; &amp;nbsp;Lee, Barbara&amp;nbsp;&amp;nbsp; &amp;nbsp;Appropriations&lt;BR /&gt;8&amp;nbsp;&amp;nbsp; &amp;nbsp;40th&amp;nbsp;&amp;nbsp; &amp;nbsp;Roybal-Allard, Lucille&amp;nbsp;&amp;nbsp; &amp;nbsp;Appropriations&lt;BR /&gt;9&amp;nbsp;&amp;nbsp; &amp;nbsp;21st&amp;nbsp;&amp;nbsp; &amp;nbsp;Valadao, David&amp;nbsp;&amp;nbsp; &amp;nbsp;Appropriations&lt;BR /&gt;10&amp;nbsp;&amp;nbsp; &amp;nbsp;24th&amp;nbsp;&amp;nbsp; &amp;nbsp;Carbajal, Salud&amp;nbsp;&amp;nbsp; &amp;nbsp;Armed Services&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've analyzed the bipartite graph whose nodes come from the name and committee assignment variables. Edges appear from name to committee assignment if that member serves on said committee.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I now want to create a new graph whose nodes are the names and an edge exists between two names if they sit on a common committee.&amp;nbsp;For example, Agriculture will generate 4 choose 2= 6 edges in the new graph, one of which is Costa-Denham.&amp;nbsp; So, I want to create a new data set from my current data set with two variables:rep1 and rep2.&amp;nbsp;&amp;nbsp; I think that I want to use nested for loops to check committee assignment for every pair of observations and if they match then output the observation names into my new data set as rep1 and rep2. My first 7 observations in the new data set would be:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Obs rep1 rep2&lt;/P&gt;&lt;P&gt;1&amp;nbsp; Costa Denham&lt;/P&gt;&lt;P&gt;2 Costa LaMalfa&lt;/P&gt;&lt;P&gt;3 Costa Panetta&lt;/P&gt;&lt;P&gt;4 Denham LaMalfa&lt;/P&gt;&lt;P&gt;5 Denham&amp;nbsp;Panetta&lt;/P&gt;&lt;P&gt;6. LaMalfa Panetta&lt;/P&gt;&lt;P&gt;7 Aguilar Calvert&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I don't know how to do, if possible in SAS, is look at the specific entries in observations to compare and then write to a new data set.&amp;nbsp; Suggestions?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Joe&lt;/P&gt;</description>
      <pubDate>Thu, 01 Feb 2018 15:19:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/random-access-to-variables-in-observations/m-p/433131#M2185</guid>
      <dc:creator>jdemaio</dc:creator>
      <dc:date>2018-02-01T15:19:41Z</dc:date>
    </item>
    <item>
      <title>Re: random access to variables in observations</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/random-access-to-variables-in-observations/m-p/433194#M2188</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc optmodel;
   set &amp;lt;str,str&amp;gt; ARCS;
   read data bipartite into ARCS=[Name CommitteeAssignment];
   create data outdata from [rep1 rep2]=(setof {&amp;lt;n1,c&amp;gt; in ARCS, &amp;lt;n2,(c)&amp;gt; in ARCS: n1 &amp;lt; n2} &amp;lt;n1,n2&amp;gt;);
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 01 Feb 2018 17:30:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/random-access-to-variables-in-observations/m-p/433194#M2188</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2018-02-01T17:30:24Z</dc:date>
    </item>
    <item>
      <title>Re: random access to variables in observations</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/random-access-to-variables-in-observations/m-p/433224#M2189</link>
      <description>&lt;P&gt;Works perfectly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Joe&lt;/P&gt;</description>
      <pubDate>Thu, 01 Feb 2018 18:45:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/random-access-to-variables-in-observations/m-p/433224#M2189</guid>
      <dc:creator>jdemaio</dc:creator>
      <dc:date>2018-02-01T18:45:09Z</dc:date>
    </item>
    <item>
      <title>Re: random access to variables in observations</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/random-access-to-variables-in-observations/m-p/433228#M2190</link>
      <description>&lt;P&gt;And here's another approach that uses PROC OPTGRAPH:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data names(keep=node source);
   set bipartite(rename=(name=node));
   source = 1;
run;
proc optgraph links=bipartite data_nodes_sub=names;
   links_var from=Name to=CommitteeAssignment;
   shortpath out_weights=outdata(rename=(source=rep1 sink=rep2) where=(rep1 &amp;lt; rep2 and path_weight=2));
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 01 Feb 2018 18:56:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/random-access-to-variables-in-observations/m-p/433228#M2190</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2018-02-01T18:56:20Z</dc:date>
    </item>
    <item>
      <title>Re: random access to variables in observations</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/random-access-to-variables-in-observations/m-p/433559#M2191</link>
      <description>&lt;P&gt;And another way with PROC SQL:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
   create table outdata as
   select a.Name as rep1, b.Name as rep2
   from bipartite as a full outer join bipartite as b
   on a.CommitteeAssignment = b.CommitteeAssignment
   where rep1 &amp;lt; rep2;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 02 Feb 2018 15:16:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/random-access-to-variables-in-observations/m-p/433559#M2191</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2018-02-02T15:16:41Z</dc:date>
    </item>
  </channel>
</rss>

