<?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: How do I define a new set from other sets in optmodel in Mathematical Optimization, Discrete-Event Simulation, and OR</title>
    <link>https://communities.sas.com/t5/Mathematical-Optimization/How-do-I-define-a-new-set-from-other-sets-in-optmodel/m-p/317983#M1571</link>
    <description>&lt;P&gt;Ok I got the idea. Thanks, It was very helpful!&lt;/P&gt;</description>
    <pubDate>Fri, 09 Dec 2016 19:55:38 GMT</pubDate>
    <dc:creator>Afdoone</dc:creator>
    <dc:date>2016-12-09T19:55:38Z</dc:date>
    <item>
      <title>How do I define a new set from other sets in optmodel</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/How-do-I-define-a-new-set-from-other-sets-in-optmodel/m-p/317932#M1566</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I got a problem with set defining since I am a beginner and I appreciate if somebody helps me here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a data set as below&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;Rank&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Person1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Next_person&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Money&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;A&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;B&lt;/P&gt;&lt;/T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p;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am skiping rest of the table here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First column is rank of the person, second column is the person and the third column is the person next to person1. The last column shows the money person1 s. I already define this set in my optmodel:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;set&amp;lt;num, str, num&amp;gt; rank_per_mny;&lt;/P&gt;&lt;P&gt;rank_per_mny = [Rank Person1 Money]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I need to have kind of a product of this set with itself to give me a set as :&lt;/P&gt;&lt;P&gt;{Rank,Person1,Money(for person1),Money(for Next_person)}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically, I want to add the next_person money to the previous set (for the same rank) and I think it is a product between this set and itself. For this example the set I need will be this:&lt;/P&gt;&lt;P&gt;{1,A,100,110}, {1,A,100,120}, , {1,A,120,110}, , {1,A,100,120}, , {2,A,120,120},&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wrote the followingcode but I it does not get the correct values. Like it should start the Money for next_person from 110 but it starts from 100 again. I appreciate your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc optmodel;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;set&amp;lt;num, str, num&amp;gt; rank_per_mny;&lt;/P&gt;&lt;P&gt;rank_per_mny = [Rank Person1 Money];&lt;/P&gt;&lt;P&gt;set&amp;lt;num, str,str, num&amp;gt; rank_per_mny_mny;&lt;/P&gt;&lt;P&gt;rank_per_mny_mny = [Rank Person1 Next_person Money];&lt;/P&gt;&lt;P&gt;set&amp;lt; number&amp;gt; money;&lt;/P&gt;&lt;P&gt;set&amp;lt; num, str, num &amp;gt; assign;&lt;/P&gt;&lt;P&gt;set&amp;lt; num, str, num,number&amp;gt; cross;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;for {&amp;lt; Rank, Person1, Next_person, Money &amp;gt; in rank_per_mny_mny }&lt;/P&gt;&lt;P&gt;money = setof{&amp;lt; Rank Next_person Money &amp;gt; in rank_per_mny } Money ;&lt;/P&gt;&lt;P&gt;assign = setof{&amp;lt; Rank Person1 Money &amp;gt; in rank_per_mny }{&amp;lt;Rank Person1 Money&amp;gt;;&lt;/P&gt;&lt;P&gt;cross = cross union (assign cross price);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 09 Dec 2016 16:25:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/How-do-I-define-a-new-set-from-other-sets-in-optmodel/m-p/317932#M1566</guid>
      <dc:creator>Afdoone</dc:creator>
      <dc:date>2016-12-09T16:25:42Z</dc:date>
    </item>
    <item>
      <title>Re: How do I define a new set from other sets in optmodel</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/How-do-I-define-a-new-set-from-other-sets-in-optmodel/m-p/317968#M1568</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data data1;
   input person $ next $;
   datalines;
A B
B C
;

data data2;
   input Rank Person1 $ Money;
   datalines;
1 A 100
1 A 120
2 A 120
1 B 110
1 B 120
2 B 120
;

proc optmodel;
   set &amp;lt;str&amp;gt; PEOPLE;
   str next {PEOPLE};
   read data data1 into PEOPLE=[person] next;

   set&amp;lt;num, str, num&amp;gt; rank_per_mny;
   read data data2 into rank_per_mny = [Rank Person1 Money];

   put (setof {&amp;lt;r,p,m&amp;gt; in rank_per_mny, &amp;lt;(r),next[p],m2&amp;gt; in rank_per_mny} &amp;lt;r,p,m,m2&amp;gt;)=;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 09 Dec 2016 19:09:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/How-do-I-define-a-new-set-from-other-sets-in-optmodel/m-p/317968#M1568</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2016-12-09T19:09:24Z</dc:date>
    </item>
    <item>
      <title>Re: How do I define a new set from other sets in optmodel</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/How-do-I-define-a-new-set-from-other-sets-in-optmodel/m-p/317980#M1570</link>
      <description>&lt;P&gt;Thank you so much! It is interesting,&amp;nbsp;so it seems next[p] gives us the person in column "next" in data1 who&amp;nbsp;is in the same raw as observation p in data2?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Dec 2016 19:52:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/How-do-I-define-a-new-set-from-other-sets-in-optmodel/m-p/317980#M1570</guid>
      <dc:creator>Afdoone</dc:creator>
      <dc:date>2016-12-09T19:52:40Z</dc:date>
    </item>
    <item>
      <title>Re: How do I define a new set from other sets in optmodel</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/How-do-I-define-a-new-set-from-other-sets-in-optmodel/m-p/317983#M1571</link>
      <description>&lt;P&gt;Ok I got the idea. Thanks, It was very helpful!&lt;/P&gt;</description>
      <pubDate>Fri, 09 Dec 2016 19:55:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/How-do-I-define-a-new-set-from-other-sets-in-optmodel/m-p/317983#M1571</guid>
      <dc:creator>Afdoone</dc:creator>
      <dc:date>2016-12-09T19:55:38Z</dc:date>
    </item>
    <item>
      <title>Re: How do I define a new set from other sets in optmodel</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/How-do-I-define-a-new-set-from-other-sets-in-optmodel/m-p/317984#M1572</link>
      <description>&lt;P&gt;yes&lt;/P&gt;</description>
      <pubDate>Fri, 09 Dec 2016 19:56:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/How-do-I-define-a-new-set-from-other-sets-in-optmodel/m-p/317984#M1572</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2016-12-09T19:56:52Z</dc:date>
    </item>
  </channel>
</rss>

