<?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: Read Data From Two Dimensional Array in Mathematical Optimization, Discrete-Event Simulation, and OR</title>
    <link>https://communities.sas.com/t5/Mathematical-Optimization/Read-Data-From-Two-Dimensional-Array/m-p/462094#M2255</link>
    <description>&lt;P&gt;Your FOR loop was reading the first line of the data set each time.&amp;nbsp; To read one observation per employee (with name as the key column), do this instead:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;read data Preferences into [name] {sh in shifts} &amp;lt;preferencesArray[name, sh] = col(sh)&amp;gt;;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can in fact combine your two READ DATA statements as follows:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;read data Preferences into employees=[name] {sh in shifts} &amp;lt;preferencesArray[name, sh] = col(sh)&amp;gt;;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;For more examples, see &lt;A href="http://go.documentation.sas.com/?docsetId=ormpex&amp;amp;docsetTarget=titlepage.htm&amp;amp;docsetVersion=14.3&amp;amp;locale=en" target="_self"&gt;SAS/OR User's Guide: Mathematical Programming Examples&lt;/A&gt;.&amp;nbsp; The pdf version has a subject index that contains entries on reading various types of data, including two-dimensional.&lt;/P&gt;</description>
    <pubDate>Mon, 14 May 2018 15:36:17 GMT</pubDate>
    <dc:creator>RobPratt</dc:creator>
    <dc:date>2018-05-14T15:36:17Z</dc:date>
    <item>
      <title>Read Data From Two Dimensional Array</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Read-Data-From-Two-Dimensional-Array/m-p/461666#M2254</link>
      <description>&lt;P&gt;Hi!&amp;nbsp; I'm new to SAS OR.&amp;nbsp; I've having trouble reading data from a two dimensional array in the read data statement in proc optmodel.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the data:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Preferences;
	length name $30. _6am_7am 3. _7am_8am 3._8am_9am 3. _9am_10am 3. _10am_11am 3. _11am_12pm 3. _12pm_1pm 3. _1pm_2pm 3. _2pm_3pm 3. _3pm_4pm 3. _4pm_5pm 3. _5pm_6pm 3. _6pm_7pm 3.;
	input name $ _6am_7am _7am_8am _8am_9am _9am_10am _10am_11am _11am_12pm _12pm_1pm _1pm_2pm _2pm_3pm _3pm_4pm _4pm_5pm _5pm_6pm _6pm_7pm;
datalines;
Evan_Boyak 1 1 0 0 0 3 3 3 4 4 3 0 0
Andrew_Miller 1 1 1 1 3 2 0 0 0 4 4 4 1
Jess_Whitaker 1 1 3 3 0 4 4 2 4 4 2 1 1
Rachel_Hartshorn 4 4 0 0 4 0 0 2 2 4 1 1 1
Mark_Hamilton 1 1 1 0 0 0 3 3 2 2 2 1 1
Jace_Webster 1 1 2 1 1 3 0 0 0 3 3 4 4
Brexton_Simonsen 0 0 1 4 4 0 3 0 0 4 1 2 4
Levi_Morse 1 1 2 2 2 2 1 1 0 0 0 0 0
Jhonny_Loaiza 2 3 0 0 3 3 2 3 4 4 4 4 3
Mitch_Lindeman 3 4 2 2 1 1 1 1 2 2 2 1 1
Joel_LaPray 1 1 0 2 0 0 2 3 3 1 1 1 4
Jenna_Hamilton 1 1 1 1 1 2 2 2 2 4 4 4 2
Dallin_Miller 1 1 0 1 0 4 0 4 4 4 2 2 1
Jimmothy_Winters 1 1 2 0 0 0 2 2 2 3 3 0 0
Daniel_Barrio 1 1 2 4 0 2 2 0 0 4 4 4 4
Alex_Walters 0 0 3 3 3 3 3 3 1 1 1 2 2
Gideon_Stowell 1 1 1 1 2 4 0 0 0 0 0 1 1
Landon_Dyer 1 1 1 2 2 2 2 2 4 4 4 4 1&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Here is my code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc optmodel;
set &amp;lt;string&amp;gt; employees;

set &amp;lt;string&amp;gt; shifts = {"_6am_7am", "_7am_8am", "_8am_9am", "_9am_10am", "_10am_11am", "_11am_12pm", "_12pm_1pm", "_1pm_2pm", "_2pm_3pm", "_3pm_4pm", "_4pm_5pm", "_5pm_6pm", "_6pm_7pm"};
read data Preferences into employees=[name];
num preferencesArray{employees, shifts};

for {name in employees} read data Preferences into {sh in shifts} &amp;lt;preferencesArray[name, sh] = col(sh)&amp;gt;;

for {name in employees} for {sh in shifts}
	put preferencesArray[name, sh]=;

quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;In my log, every employee has the same shift preferences.&amp;nbsp; Only the first line of preference weights is being read.&amp;nbsp; What is the syntax for reading in such a two dimensional array?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 11 May 2018 18:45:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Read-Data-From-Two-Dimensional-Array/m-p/461666#M2254</guid>
      <dc:creator>yus03590</dc:creator>
      <dc:date>2018-05-11T18:45:50Z</dc:date>
    </item>
    <item>
      <title>Re: Read Data From Two Dimensional Array</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Read-Data-From-Two-Dimensional-Array/m-p/462094#M2255</link>
      <description>&lt;P&gt;Your FOR loop was reading the first line of the data set each time.&amp;nbsp; To read one observation per employee (with name as the key column), do this instead:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;read data Preferences into [name] {sh in shifts} &amp;lt;preferencesArray[name, sh] = col(sh)&amp;gt;;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can in fact combine your two READ DATA statements as follows:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;read data Preferences into employees=[name] {sh in shifts} &amp;lt;preferencesArray[name, sh] = col(sh)&amp;gt;;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;For more examples, see &lt;A href="http://go.documentation.sas.com/?docsetId=ormpex&amp;amp;docsetTarget=titlepage.htm&amp;amp;docsetVersion=14.3&amp;amp;locale=en" target="_self"&gt;SAS/OR User's Guide: Mathematical Programming Examples&lt;/A&gt;.&amp;nbsp; The pdf version has a subject index that contains entries on reading various types of data, including two-dimensional.&lt;/P&gt;</description>
      <pubDate>Mon, 14 May 2018 15:36:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Read-Data-From-Two-Dimensional-Array/m-p/462094#M2255</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2018-05-14T15:36:17Z</dc:date>
    </item>
  </channel>
</rss>

