<?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: Error: array element has no value in SAS Software for Learning Community</title>
    <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Error-array-element-has-no-value/m-p/944170#M2319</link>
    <description>&lt;P&gt;Dear Paige and Jackie,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much for fast response. Here is the log of when I run the code. Please do let me know if I'm not pasting the right thing. I am fairly new to SAS and the community.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt; 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 68         
 69         /* Patient data: duration of treatment and revenue */
 70         data patient_data;
 71             input i duration revenue;
 72             datalines;
 
 NOTE: The data set WORK.PATIENT_DATA has 10 observations and 3 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       user cpu time       0.01 seconds
       system cpu time     0.00 seconds
       memory              666.03k
       OS Memory           19620.00k
       Timestamp           09/17/2024 12:23:14 AM
       Step Count                        24  Switch Count  2
       Page Faults                       0
       Page Reclaims                     136
       Page Swaps                        0
       Voluntary Context Switches        11
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           264
       
 
 83         ;
 84         run;
 85         
 86         /* Travel times between patients (symmetric for simplicity) */
 87         data travel_times;
 88             input i j t;
 89             datalines;
 
 NOTE: The data set WORK.TRAVEL_TIMES has 55 observations and 3 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              666.03k
       OS Memory           19620.00k
       Timestamp           09/17/2024 12:23:14 AM
       Step Count                        25  Switch Count  2
       Page Faults                       0
       Page Reclaims                     91
       Page Swaps                        0
       Voluntary Context Switches        11
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           264
       
 
 145        ;
 146        run;
 147        
 148        /* Generate full travel time matrix */
 149        data travel_times_full;
 150            set travel_times;
 151            output;
 152            t_temp = t;
 153            t = t_temp;
 154            i_temp = i;
 155            i = j;
 156            j = i_temp;
 157            output;
 158        run;
 
 NOTE: There were 55 observations read from the data set WORK.TRAVEL_TIMES.
 NOTE: The data set WORK.TRAVEL_TIMES_FULL has 110 observations and 5 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              947.40k
       OS Memory           19880.00k
       Timestamp           09/17/2024 12:23:14 AM
       Step Count                        26  Switch Count  2
       Page Faults                       0
       Page Reclaims                     122
       Page Swaps                        0
       Voluntary Context Switches        10
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           272
       
 
 159        
 160        /* Add diagonal elements (travel time to self = 0) */
 161        data travel_times_final;
 162            set travel_times_full;
 163            do i = 1 to 10;
 164                j = i;
 165                t = 0;
 166                output;
 167            end;
 168        run;
 
 NOTE: There were 110 observations read from the data set WORK.TRAVEL_TIMES_FULL.
 NOTE: The data set WORK.TRAVEL_TIMES_FINAL has 1100 observations and 5 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              941.93k
       OS Memory           19880.00k
       Timestamp           09/17/2024 12:23:14 AM
       Step Count                        27  Switch Count  2
       Page Faults                       0
       Page Reclaims                     109
       Page Swaps                        0
       Voluntary Context Switches        12
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           264
       
 
 169        
 170        /* Nurse and vehicle data */
 171        data nurse_data;
 172            input H_t H_c c_t c_c c_v n_t;
 173            datalines;
 
 NOTE: The data set WORK.NURSE_DATA has 1 observations and 6 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       user cpu time       0.01 seconds
       system cpu time     0.00 seconds
       memory              668.03k
       OS Memory           19620.00k
       Timestamp           09/17/2024 12:23:14 AM
       Step Count                        28  Switch Count  2
       Page Faults                       0
       Page Reclaims                     85
       Page Swaps                        0
       Voluntary Context Switches        12
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           264
       
 
 175        ;
 176        run;
 177        
 178        /* Macro to set the number of telehealth nurses */
 179        %let n_t = 20;
 180        
 181        /* Use PROC OPTMODEL to solve the problem */
 182        proc optmodel;
 183            /* Define sets */
 184            set PATIENTS = 1..10;
 185            set TELEHEALTH_NURSES = 1..&amp;amp;n_t;
 186            set TRAVEL_CAREGIVERS = 1..8;
 187            set VEHICLES = 1..4;
 188        
 189            /* Define parameters */
 190            number d{PATIENTS};
 191            number travel_time{PATIENTS, PATIENTS};
 192            number H_t;
 193            number H_c;
 194            number r{PATIENTS};
 195            number c_t;
 196            number c_c;
 197            number c_v;
 198        
 199            /* Read data */
 200           read data patient_data into [i] d=duration r=revenue;
 NOTE: There were 10 observations read from the data set WORK.PATIENT_DATA.
 201           read data travel_times_final into [i j] travel_time=t;
 WARNING: Duplicate key &amp;lt;1,1&amp;gt; was read at observation 11.
 WARNING: Duplicate key &amp;lt;2,2&amp;gt; was read at observation 12.
 WARNING: Duplicate key &amp;lt;3,3&amp;gt; was read at observation 13.
 WARNING: Duplicate key &amp;lt;4,4&amp;gt; was read at observation 14.
 WARNING: Duplicate key &amp;lt;5,5&amp;gt; was read at observation 15.
 WARNING: Duplicate key &amp;lt;6,6&amp;gt; was read at observation 16.
 WARNING: Duplicate key &amp;lt;7,7&amp;gt; was read at observation 17.
 WARNING: Duplicate key &amp;lt;8,8&amp;gt; was read at observation 18.
 WARNING: Duplicate key &amp;lt;9,9&amp;gt; was read at observation 19.
 WARNING: Duplicate key &amp;lt;10,10&amp;gt; was read at observation 20.
 WARNING: Duplicate key &amp;lt;1,1&amp;gt; was read at observation 21.
 WARNING: Duplicate key &amp;lt;2,2&amp;gt; was read at observation 22.
 WARNING: Duplicate key &amp;lt;3,3&amp;gt; was read at observation 23.
 WARNING: Duplicate key &amp;lt;4,4&amp;gt; was read at observation 24.
 WARNING: Duplicate key &amp;lt;5,5&amp;gt; was read at observation 25.
 WARNING: Duplicate key &amp;lt;6,6&amp;gt; was read at observation 26.
 WARNING: Duplicate key &amp;lt;7,7&amp;gt; was read at observation 27.
 WARNING: Duplicate key &amp;lt;8,8&amp;gt; was read at observation 28.
 WARNING: Duplicate key &amp;lt;9,9&amp;gt; was read at observation 29.
 WARNING: Duplicate key &amp;lt;10,10&amp;gt; was read at observation 30.
 WARNING: Duplicate key &amp;lt;1,1&amp;gt; was read at observation 31.
 WARNING: Duplicate key &amp;lt;2,2&amp;gt; was read at observation 32.
 WARNING: Duplicate key &amp;lt;3,3&amp;gt; was read at observation 33.
 WARNING: Duplicate key &amp;lt;4,4&amp;gt; was read at observation 34.
 WARNING: Duplicate key &amp;lt;5,5&amp;gt; was read at observation 35.
 NOTE: 1090 duplicate keys were read.
 NOTE: There were 1100 observations read from the data set WORK.TRAVEL_TIMES_FINAL.
 NOTE: The maximum message limit was reached during execution of the statement block. 1065 notes and warnings were not displayed.
 202           read data nurse_data into H_t H_c c_t c_c c_v;
 NOTE: There were 1 observations read from the data set WORK.NURSE_DATA.
 203        
 204           /* Define variables */
 205           var X{PATIENTS, TELEHEALTH_NURSES} binary;
 206           var Y{PATIENTS, TRAVEL_CAREGIVERS} binary;
 207           var Z{PATIENTS, PATIENTS, TRAVEL_CAREGIVERS, VEHICLES} binary;
 208           var U{PATIENTS} integer &amp;gt;= 1 &amp;lt;= card(PATIENTS);
 209        
 210           /* Objective function */
 211           max Profit = sum{i in PATIENTS} (r[i] * (sum{tn in TELEHEALTH_NURSES} X[i,tn] +
 212                        sum{c in TRAVEL_CAREGIVERS} Y[i,c]))
 213                        - sum{tn in TELEHEALTH_NURSES} (c_t * sum{i in PATIENTS} d[i] * X[i,tn])
 214                        - sum{c in TRAVEL_CAREGIVERS} (c_c * (sum{i in PATIENTS} d[i] * Y[i,c] +
 215                          sum{i in PATIENTS, j in PATIENTS, v in VEHICLES} travel_time[i,j] * Z[i,j,c,v]))
 216                        - sum{v in VEHICLES} (c_v * sum{c in TRAVEL_CAREGIVERS, i in PATIENTS, j in PATIENTS}
 217                          travel_time[i,j] * Z[i,j,c,v]);
 218        
 219           /* Constraints */
 220           con Patient_Assignment{i in PATIENTS}:
 221               sum{tn in TELEHEALTH_NURSES} X[i,tn] + sum{c in TRAVEL_CAREGIVERS} Y[i,c] = 1;
 222        
 223           con Telehealth_Hours{tn in TELEHEALTH_NURSES}:
 224               sum{i in PATIENTS} d[i] * X[i,tn] &amp;lt;= H_t;
 225        
 226           con Travel_Caregiver_Hours{c in TRAVEL_CAREGIVERS}:
 227               sum{i in PATIENTS} d[i] * Y[i,c] +
 228               sum{i in PATIENTS, j in PATIENTS, v in VEHICLES} travel_time[i,j] * Z[i,j,c,v] &amp;lt;= H_c;
 229        
 230           con Vehicle_Capacity{v in VEHICLES}:
 231               sum{c in TRAVEL_CAREGIVERS, i in PATIENTS, j in PATIENTS} Z[i,j,c,v] &amp;lt;= 2;
 232        
 233        
 234           con Flow_Conservation{i in PATIENTS, c in TRAVEL_CAREGIVERS}:
 235               sum{j in PATIENTS, v in VEHICLES} Z[i,j,c,v] = Y[i,c];
 236        
 237           con Flow_Conservation_Reverse{i in PATIENTS, c in TRAVEL_CAREGIVERS}:
 238               sum{j in PATIENTS, v in VEHICLES} Z[j,i,c,v] = Y[i,c];
 239        
 240           con Subtour_Elimination{i in PATIENTS, j in PATIENTS, c in TRAVEL_CAREGIVERS: i ne j}:
 241               U[i] - U[j] + 1 &amp;lt;= card(PATIENTS) * (1 - sum{v in VEHICLES} Z[i,j,c,v]);
 242        
 243           con Ordering_Link{i in PATIENTS, c in TRAVEL_CAREGIVERS}:
 244               U[i] &amp;gt;= 1 + card(PATIENTS) * (Y[i,c] - 1);
 245        
 246           /* Solve the model */
 247           solve;
 NOTE: Problem generation will use 2 threads.
 ERROR: The array element 'travel_time[1,2]' has no value at line 228 column 57.
 ERROR: The array element 'travel_time[1,2]' has no value at line 228 column 57.
 NOTE: Unable to create problem instance due to previous errors.
 248        
 249           /* Print results */
 250           print X Y Z U;
 251        quit;
 NOTE: The SAS System stopped processing this step because of errors.
 NOTE: PROCEDURE OPTMODEL used (Total process time):
       real time           1.61 seconds
       user cpu time       1.59 seconds
       system cpu time     0.01 seconds
       memory              3191.06k
       OS Memory           22456.00k
       Timestamp           09/17/2024 12:23:16 AM
       Step Count                        29  Switch Count  5
       Page Faults                       0
       Page Reclaims                     1146
       Page Swaps                        0
       Voluntary Context Switches        52
       Involuntary Context Switches      3
       Block Input Operations            0
       Block Output Operations           1816
       
 252        
 253        
 254        
 255        OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 265        &lt;/PRE&gt;</description>
    <pubDate>Tue, 17 Sep 2024 00:25:49 GMT</pubDate>
    <dc:creator>norachanisara</dc:creator>
    <dc:date>2024-09-17T00:25:49Z</dc:date>
    <item>
      <title>Error: array element has no value</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Error-array-element-has-no-value/m-p/944085#M2316</link>
      <description>&lt;P&gt;My SAS code&amp;nbsp; is generating semantic error. It is saying&amp;nbsp;&lt;SPAN&gt;ERROR: The array element 'travel_time[1,2]' has no value at line 228 column 57.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am not sure what that means. I believe the data is completed and has been loaded in correctly.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;/* Patient data: duration of treatment and revenue */
data patient_data;
    input i duration revenue;
    datalines;
1   12  200
2   45  181
3   90  255
4   26  150
5   75  220
6   60  200
7   45  180
8   120 300
9   90  250
10  30  158
;
run;

/* Travel times between patients (symmetric for simplicity) */
data travel_times;
    input i j t;
    datalines;
1  2  15
1  3  20
1  4  25
1  5  30
1  6  3.5
1  7  11
1  8  26
1  9  12
1  10  26
2  3  10
2  4  18
2  5  22
2  6  10
2  7  3
2  8  4
2  9  5.5
2  10  15
3  4  12
3  5  15
3  6  10
3  7  25
3  8  30
3  9  22
3  10  12
4  5  8
4  6  23
4  7  10
4  8  7.5
4  9  6.5
4  10  48
5  6  28
5  7  10
5  8  15
5  9  16
5  10  45
6  7  28
6  8  45
6  9  30
6  10  25
7  8  12
7  9  10
7  10  4
8  9  3.5
8  10  15
9  10  30
1  1  0
2  2  0
3  3  0
4  4  0
5  5  0
6  6  0
7  7  0
8  8  0
9  9  0
10  10  0
;
run;

/* Generate full travel time matrix */
data travel_times_full;
    set travel_times;
    output;
    t_temp = t;
    t = t_temp;
    i_temp = i;
    i = j;
    j = i_temp;
    output;
run;

/* Add diagonal elements (travel time to self = 0) */
data travel_times_final;
    set travel_times_full;
    do i = 1 to 10;
        j = i;
        t = 0;
        output;
    end;
run;

/* Nurse and vehicle data */
data nurse_data;
    input H_t H_c c_t c_c c_v n_t;
    datalines;
480 480 30 40 20 8
;
run;

/* Macro to set the number of telehealth nurses */
%let n_t = 20;

/* Use PROC OPTMODEL to solve the problem */
proc optmodel;
    /* Define sets */
    set PATIENTS = 1..10;
    set TELEHEALTH_NURSES = 1..&amp;amp;n_t;
    set TRAVEL_CAREGIVERS = 1..8;
    set VEHICLES = 1..4;

    /* Define parameters */
    number d{PATIENTS};
    number travel_time{PATIENTS, PATIENTS};
    number H_t;
    number H_c;
    number r{PATIENTS};
    number c_t;
    number c_c;
    number c_v;

    /* Read data */
   read data patient_data into [i] d=duration r=revenue;
   read data travel_times_final into [i j] travel_time=t;
   read data nurse_data into H_t H_c c_t c_c c_v;

   /* Define variables */
   var X{PATIENTS, TELEHEALTH_NURSES} binary;
   var Y{PATIENTS, TRAVEL_CAREGIVERS} binary;
   var Z{PATIENTS, PATIENTS, TRAVEL_CAREGIVERS, VEHICLES} binary;
   var U{PATIENTS} integer &amp;gt;= 1 &amp;lt;= card(PATIENTS);

   /* Objective function */
   max Profit = sum{i in PATIENTS} (r[i] * (sum{tn in TELEHEALTH_NURSES} X[i,tn] + 
                sum{c in TRAVEL_CAREGIVERS} Y[i,c]))
                - sum{tn in TELEHEALTH_NURSES} (c_t * sum{i in PATIENTS} d[i] * X[i,tn])
                - sum{c in TRAVEL_CAREGIVERS} (c_c * (sum{i in PATIENTS} d[i] * Y[i,c] + 
                  sum{i in PATIENTS, j in PATIENTS, v in VEHICLES} travel_time[i,j] * Z[i,j,c,v]))
                - sum{v in VEHICLES} (c_v * sum{c in TRAVEL_CAREGIVERS, i in PATIENTS, j in PATIENTS} 
                  travel_time[i,j] * Z[i,j,c,v]);

   /* Constraints */
   con Patient_Assignment{i in PATIENTS}:
       sum{tn in TELEHEALTH_NURSES} X[i,tn] + sum{c in TRAVEL_CAREGIVERS} Y[i,c] = 1;

   con Telehealth_Hours{tn in TELEHEALTH_NURSES}:
       sum{i in PATIENTS} d[i] * X[i,tn] &amp;lt;= H_t;

   con Travel_Caregiver_Hours{c in TRAVEL_CAREGIVERS}:
       sum{i in PATIENTS} d[i] * Y[i,c] + 
       sum{i in PATIENTS, j in PATIENTS, v in VEHICLES} travel_time[i,j] * Z[i,j,c,v] &amp;lt;= H_c;

   con Vehicle_Capacity{v in VEHICLES}:
       sum{c in TRAVEL_CAREGIVERS, i in PATIENTS, j in PATIENTS} Z[i,j,c,v] &amp;lt;= 2;

       
   con Flow_Conservation{i in PATIENTS, c in TRAVEL_CAREGIVERS}:
       sum{j in PATIENTS, v in VEHICLES} Z[i,j,c,v] = Y[i,c];

   con Flow_Conservation_Reverse{i in PATIENTS, c in TRAVEL_CAREGIVERS}:
       sum{j in PATIENTS, v in VEHICLES} Z[j,i,c,v] = Y[i,c];    

   con Subtour_Elimination{i in PATIENTS, j in PATIENTS, c in TRAVEL_CAREGIVERS: i ne j}:
       U[i] - U[j] + 1 &amp;lt;= card(PATIENTS) * (1 - sum{v in VEHICLES} Z[i,j,c,v]);

   con Ordering_Link{i in PATIENTS, c in TRAVEL_CAREGIVERS}:
       U[i] &amp;gt;= 1 + card(PATIENTS) * (Y[i,c] - 1);

   /* Solve the model */
   solve;

   /* Print results */
   print X Y Z U;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Sep 2024 14:16:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Error-array-element-has-no-value/m-p/944085#M2316</guid>
      <dc:creator>norachanisara</dc:creator>
      <dc:date>2024-09-16T14:16:38Z</dc:date>
    </item>
    <item>
      <title>Re: Error: array element has no value</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Error-array-element-has-no-value/m-p/944087#M2317</link>
      <description>&lt;P&gt;Please, when you get an error, show us the log, including the code as it appears in the log, and any ERROR or WARNING or NOTE message.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the problem occurs in a specific PROC, just show us the log for that PROC.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please click on the &amp;lt;/&amp;gt; icon, paste your log as text (not a screen capture) into the window that appears.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PaigeMiller_0-1715196634946.png" style="width: 859px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/96351i414DE7EE2D1B5DE6/image-size/large?v=v2&amp;amp;px=999" role="button" title="PaigeMiller_0-1715196634946.png" alt="PaigeMiller_0-1715196634946.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Sep 2024 14:20:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Error-array-element-has-no-value/m-p/944087#M2317</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-09-16T14:20:18Z</dc:date>
    </item>
    <item>
      <title>Re: Error: array element has no value</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Error-array-element-has-no-value/m-p/944124#M2318</link>
      <description>&lt;P&gt;I'll second that we do need to see the log to be able to help with this. You mentioned this error message:&lt;/P&gt;
&lt;PRE&gt;ERROR: The array element 'travel_time[1,2]' has no value at line 228 column 57&lt;/PRE&gt;
&lt;P&gt;A search of your program shows that travel_time is used several times, so, without the log, we can't tell which part is causing the issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The line and column numbers mentioned in the error are referring to notes in the log. For example, say your log looked like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;      
 73         data temp;
 74         set sashelp.heart;
 75         array one{3};
 76         do i=1 to 4;
 77         myar=one[i];
 78         end;
 79         run;
 
 ERROR: Array subscript out of range at line 77 column 6.
 NOTE: The SAS System stopped processing this step because of errors.
 NOTE: There were 1 observations read from the data set SASHELP.HEART.&lt;/PRE&gt;
&lt;P&gt;Line 77 is referring to line 77 in the log (myvar=one[i];), and column 6 is referring to the sixth letter in line 77 (the letter o of one).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Sep 2024 18:26:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Error-array-element-has-no-value/m-p/944124#M2318</guid>
      <dc:creator>JackieJ_SAS</dc:creator>
      <dc:date>2024-09-16T18:26:24Z</dc:date>
    </item>
    <item>
      <title>Re: Error: array element has no value</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Error-array-element-has-no-value/m-p/944170#M2319</link>
      <description>&lt;P&gt;Dear Paige and Jackie,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much for fast response. Here is the log of when I run the code. Please do let me know if I'm not pasting the right thing. I am fairly new to SAS and the community.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt; 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 68         
 69         /* Patient data: duration of treatment and revenue */
 70         data patient_data;
 71             input i duration revenue;
 72             datalines;
 
 NOTE: The data set WORK.PATIENT_DATA has 10 observations and 3 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       user cpu time       0.01 seconds
       system cpu time     0.00 seconds
       memory              666.03k
       OS Memory           19620.00k
       Timestamp           09/17/2024 12:23:14 AM
       Step Count                        24  Switch Count  2
       Page Faults                       0
       Page Reclaims                     136
       Page Swaps                        0
       Voluntary Context Switches        11
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           264
       
 
 83         ;
 84         run;
 85         
 86         /* Travel times between patients (symmetric for simplicity) */
 87         data travel_times;
 88             input i j t;
 89             datalines;
 
 NOTE: The data set WORK.TRAVEL_TIMES has 55 observations and 3 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              666.03k
       OS Memory           19620.00k
       Timestamp           09/17/2024 12:23:14 AM
       Step Count                        25  Switch Count  2
       Page Faults                       0
       Page Reclaims                     91
       Page Swaps                        0
       Voluntary Context Switches        11
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           264
       
 
 145        ;
 146        run;
 147        
 148        /* Generate full travel time matrix */
 149        data travel_times_full;
 150            set travel_times;
 151            output;
 152            t_temp = t;
 153            t = t_temp;
 154            i_temp = i;
 155            i = j;
 156            j = i_temp;
 157            output;
 158        run;
 
 NOTE: There were 55 observations read from the data set WORK.TRAVEL_TIMES.
 NOTE: The data set WORK.TRAVEL_TIMES_FULL has 110 observations and 5 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              947.40k
       OS Memory           19880.00k
       Timestamp           09/17/2024 12:23:14 AM
       Step Count                        26  Switch Count  2
       Page Faults                       0
       Page Reclaims                     122
       Page Swaps                        0
       Voluntary Context Switches        10
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           272
       
 
 159        
 160        /* Add diagonal elements (travel time to self = 0) */
 161        data travel_times_final;
 162            set travel_times_full;
 163            do i = 1 to 10;
 164                j = i;
 165                t = 0;
 166                output;
 167            end;
 168        run;
 
 NOTE: There were 110 observations read from the data set WORK.TRAVEL_TIMES_FULL.
 NOTE: The data set WORK.TRAVEL_TIMES_FINAL has 1100 observations and 5 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              941.93k
       OS Memory           19880.00k
       Timestamp           09/17/2024 12:23:14 AM
       Step Count                        27  Switch Count  2
       Page Faults                       0
       Page Reclaims                     109
       Page Swaps                        0
       Voluntary Context Switches        12
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           264
       
 
 169        
 170        /* Nurse and vehicle data */
 171        data nurse_data;
 172            input H_t H_c c_t c_c c_v n_t;
 173            datalines;
 
 NOTE: The data set WORK.NURSE_DATA has 1 observations and 6 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       user cpu time       0.01 seconds
       system cpu time     0.00 seconds
       memory              668.03k
       OS Memory           19620.00k
       Timestamp           09/17/2024 12:23:14 AM
       Step Count                        28  Switch Count  2
       Page Faults                       0
       Page Reclaims                     85
       Page Swaps                        0
       Voluntary Context Switches        12
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           264
       
 
 175        ;
 176        run;
 177        
 178        /* Macro to set the number of telehealth nurses */
 179        %let n_t = 20;
 180        
 181        /* Use PROC OPTMODEL to solve the problem */
 182        proc optmodel;
 183            /* Define sets */
 184            set PATIENTS = 1..10;
 185            set TELEHEALTH_NURSES = 1..&amp;amp;n_t;
 186            set TRAVEL_CAREGIVERS = 1..8;
 187            set VEHICLES = 1..4;
 188        
 189            /* Define parameters */
 190            number d{PATIENTS};
 191            number travel_time{PATIENTS, PATIENTS};
 192            number H_t;
 193            number H_c;
 194            number r{PATIENTS};
 195            number c_t;
 196            number c_c;
 197            number c_v;
 198        
 199            /* Read data */
 200           read data patient_data into [i] d=duration r=revenue;
 NOTE: There were 10 observations read from the data set WORK.PATIENT_DATA.
 201           read data travel_times_final into [i j] travel_time=t;
 WARNING: Duplicate key &amp;lt;1,1&amp;gt; was read at observation 11.
 WARNING: Duplicate key &amp;lt;2,2&amp;gt; was read at observation 12.
 WARNING: Duplicate key &amp;lt;3,3&amp;gt; was read at observation 13.
 WARNING: Duplicate key &amp;lt;4,4&amp;gt; was read at observation 14.
 WARNING: Duplicate key &amp;lt;5,5&amp;gt; was read at observation 15.
 WARNING: Duplicate key &amp;lt;6,6&amp;gt; was read at observation 16.
 WARNING: Duplicate key &amp;lt;7,7&amp;gt; was read at observation 17.
 WARNING: Duplicate key &amp;lt;8,8&amp;gt; was read at observation 18.
 WARNING: Duplicate key &amp;lt;9,9&amp;gt; was read at observation 19.
 WARNING: Duplicate key &amp;lt;10,10&amp;gt; was read at observation 20.
 WARNING: Duplicate key &amp;lt;1,1&amp;gt; was read at observation 21.
 WARNING: Duplicate key &amp;lt;2,2&amp;gt; was read at observation 22.
 WARNING: Duplicate key &amp;lt;3,3&amp;gt; was read at observation 23.
 WARNING: Duplicate key &amp;lt;4,4&amp;gt; was read at observation 24.
 WARNING: Duplicate key &amp;lt;5,5&amp;gt; was read at observation 25.
 WARNING: Duplicate key &amp;lt;6,6&amp;gt; was read at observation 26.
 WARNING: Duplicate key &amp;lt;7,7&amp;gt; was read at observation 27.
 WARNING: Duplicate key &amp;lt;8,8&amp;gt; was read at observation 28.
 WARNING: Duplicate key &amp;lt;9,9&amp;gt; was read at observation 29.
 WARNING: Duplicate key &amp;lt;10,10&amp;gt; was read at observation 30.
 WARNING: Duplicate key &amp;lt;1,1&amp;gt; was read at observation 31.
 WARNING: Duplicate key &amp;lt;2,2&amp;gt; was read at observation 32.
 WARNING: Duplicate key &amp;lt;3,3&amp;gt; was read at observation 33.
 WARNING: Duplicate key &amp;lt;4,4&amp;gt; was read at observation 34.
 WARNING: Duplicate key &amp;lt;5,5&amp;gt; was read at observation 35.
 NOTE: 1090 duplicate keys were read.
 NOTE: There were 1100 observations read from the data set WORK.TRAVEL_TIMES_FINAL.
 NOTE: The maximum message limit was reached during execution of the statement block. 1065 notes and warnings were not displayed.
 202           read data nurse_data into H_t H_c c_t c_c c_v;
 NOTE: There were 1 observations read from the data set WORK.NURSE_DATA.
 203        
 204           /* Define variables */
 205           var X{PATIENTS, TELEHEALTH_NURSES} binary;
 206           var Y{PATIENTS, TRAVEL_CAREGIVERS} binary;
 207           var Z{PATIENTS, PATIENTS, TRAVEL_CAREGIVERS, VEHICLES} binary;
 208           var U{PATIENTS} integer &amp;gt;= 1 &amp;lt;= card(PATIENTS);
 209        
 210           /* Objective function */
 211           max Profit = sum{i in PATIENTS} (r[i] * (sum{tn in TELEHEALTH_NURSES} X[i,tn] +
 212                        sum{c in TRAVEL_CAREGIVERS} Y[i,c]))
 213                        - sum{tn in TELEHEALTH_NURSES} (c_t * sum{i in PATIENTS} d[i] * X[i,tn])
 214                        - sum{c in TRAVEL_CAREGIVERS} (c_c * (sum{i in PATIENTS} d[i] * Y[i,c] +
 215                          sum{i in PATIENTS, j in PATIENTS, v in VEHICLES} travel_time[i,j] * Z[i,j,c,v]))
 216                        - sum{v in VEHICLES} (c_v * sum{c in TRAVEL_CAREGIVERS, i in PATIENTS, j in PATIENTS}
 217                          travel_time[i,j] * Z[i,j,c,v]);
 218        
 219           /* Constraints */
 220           con Patient_Assignment{i in PATIENTS}:
 221               sum{tn in TELEHEALTH_NURSES} X[i,tn] + sum{c in TRAVEL_CAREGIVERS} Y[i,c] = 1;
 222        
 223           con Telehealth_Hours{tn in TELEHEALTH_NURSES}:
 224               sum{i in PATIENTS} d[i] * X[i,tn] &amp;lt;= H_t;
 225        
 226           con Travel_Caregiver_Hours{c in TRAVEL_CAREGIVERS}:
 227               sum{i in PATIENTS} d[i] * Y[i,c] +
 228               sum{i in PATIENTS, j in PATIENTS, v in VEHICLES} travel_time[i,j] * Z[i,j,c,v] &amp;lt;= H_c;
 229        
 230           con Vehicle_Capacity{v in VEHICLES}:
 231               sum{c in TRAVEL_CAREGIVERS, i in PATIENTS, j in PATIENTS} Z[i,j,c,v] &amp;lt;= 2;
 232        
 233        
 234           con Flow_Conservation{i in PATIENTS, c in TRAVEL_CAREGIVERS}:
 235               sum{j in PATIENTS, v in VEHICLES} Z[i,j,c,v] = Y[i,c];
 236        
 237           con Flow_Conservation_Reverse{i in PATIENTS, c in TRAVEL_CAREGIVERS}:
 238               sum{j in PATIENTS, v in VEHICLES} Z[j,i,c,v] = Y[i,c];
 239        
 240           con Subtour_Elimination{i in PATIENTS, j in PATIENTS, c in TRAVEL_CAREGIVERS: i ne j}:
 241               U[i] - U[j] + 1 &amp;lt;= card(PATIENTS) * (1 - sum{v in VEHICLES} Z[i,j,c,v]);
 242        
 243           con Ordering_Link{i in PATIENTS, c in TRAVEL_CAREGIVERS}:
 244               U[i] &amp;gt;= 1 + card(PATIENTS) * (Y[i,c] - 1);
 245        
 246           /* Solve the model */
 247           solve;
 NOTE: Problem generation will use 2 threads.
 ERROR: The array element 'travel_time[1,2]' has no value at line 228 column 57.
 ERROR: The array element 'travel_time[1,2]' has no value at line 228 column 57.
 NOTE: Unable to create problem instance due to previous errors.
 248        
 249           /* Print results */
 250           print X Y Z U;
 251        quit;
 NOTE: The SAS System stopped processing this step because of errors.
 NOTE: PROCEDURE OPTMODEL used (Total process time):
       real time           1.61 seconds
       user cpu time       1.59 seconds
       system cpu time     0.01 seconds
       memory              3191.06k
       OS Memory           22456.00k
       Timestamp           09/17/2024 12:23:16 AM
       Step Count                        29  Switch Count  5
       Page Faults                       0
       Page Reclaims                     1146
       Page Swaps                        0
       Voluntary Context Switches        52
       Involuntary Context Switches      3
       Block Input Operations            0
       Block Output Operations           1816
       
 252        
 253        
 254        
 255        OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 265        &lt;/PRE&gt;</description>
      <pubDate>Tue, 17 Sep 2024 00:25:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Error-array-element-has-no-value/m-p/944170#M2319</guid>
      <dc:creator>norachanisara</dc:creator>
      <dc:date>2024-09-17T00:25:49Z</dc:date>
    </item>
    <item>
      <title>Re: Error: array element has no value</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Error-array-element-has-no-value/m-p/944171#M2320</link>
      <description>Post your question at SAS/OR Forum:&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/Mathematical-Optimization/bd-p/operations_research" target="_blank"&gt;https://communities.sas.com/t5/Mathematical-Optimization/bd-p/operations_research&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;And calling out &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/1636"&gt;@RobPratt&lt;/a&gt;</description>
      <pubDate>Tue, 17 Sep 2024 00:48:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Error-array-element-has-no-value/m-p/944171#M2320</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-09-17T00:48:40Z</dc:date>
    </item>
    <item>
      <title>Re: Error: array element has no value</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Error-array-element-has-no-value/m-p/944176#M2321</link>
      <description>&lt;P&gt;From your LOG:&lt;/P&gt;
&lt;PRE&gt;200           read data patient_data into [i] d=duration r=revenue;
 NOTE: There were 10 observations read from the data set WORK.PATIENT_DATA.
 201           read data travel_times_final into [i j] travel_time=t;
&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt; WARNING: Duplicate key &amp;lt;1,1&amp;gt; was read at observation 11.
 WARNING: Duplicate key &amp;lt;2,2&amp;gt; was read at observation 12.
 WARNING: Duplicate key &amp;lt;3,3&amp;gt; was read at observation 13.
 WARNING: Duplicate key &amp;lt;4,4&amp;gt; was read at observation 14.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;That imply your INDEX variable PATIENTS&lt;/P&gt;
&lt;PRE&gt; travel_time{PATIENTS, PATIENTS};&amp;nbsp;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;have duplicated values as showed in following picture:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_1-1726535414350.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/100400i21490B6F2D67EEC1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_1-1726535414350.png" alt="Ksharp_1-1726535414350.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Due to index variable can not have duplicated values ,you either using a DO LOOP to read it in one by one or make a unique index value to read it all .&lt;/P&gt;</description>
      <pubDate>Tue, 17 Sep 2024 01:10:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Error-array-element-has-no-value/m-p/944176#M2321</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-09-17T01:10:21Z</dc:date>
    </item>
    <item>
      <title>Re: Error: array element has no value</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Error-array-element-has-no-value/m-p/944184#M2322</link>
      <description>&lt;P&gt;Your DATA steps lost some of the data.&amp;nbsp; Here's a simpler approach, just reading from the original travel_times data:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*   read data travel_times_final into [i j] travel_time=t;*/
   read data travel_times into [i j] travel_time=t;
   for {i in PATIENTS} travel_time[i,i] = 0;
   for {i in PATIENTS, j in PATIENTS: travel_time[i,j] = _NIL_} travel_time[i,j] = travel_time[j,i];
   print travel_time;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 17 Sep 2024 01:50:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Error-array-element-has-no-value/m-p/944184#M2322</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2024-09-17T01:50:00Z</dc:date>
    </item>
    <item>
      <title>Re: Error: array element has no value</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Error-array-element-has-no-value/m-p/944189#M2323</link>
      <description>&lt;P&gt;Thank you very much Rob. I have encountered this problem quite a few times. Would you recommend inputting distance data directly as a matrix?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;for example&lt;/P&gt;&lt;P&gt;num d{P,P} = [&lt;/P&gt;&lt;P&gt;0&amp;nbsp; 42.00&amp;nbsp; 44.159&amp;nbsp; 23.43&amp;nbsp; 41.38&lt;BR /&gt;42.00&amp;nbsp; 0&amp;nbsp; 3.50&amp;nbsp; 18.70&amp;nbsp; 0.76&lt;BR /&gt;44.15&amp;nbsp; 3.50&amp;nbsp; 0&amp;nbsp; 21.17&amp;nbsp; 3.58&lt;BR /&gt;23.43&amp;nbsp; 18.70&amp;nbsp; 21.17&amp;nbsp; 0&amp;nbsp; 18.13&lt;BR /&gt;41.38&amp;nbsp; 0.76&amp;nbsp; 3.58&amp;nbsp; 18.13&amp;nbsp; 0&lt;/P&gt;&lt;P&gt;];&lt;/P&gt;</description>
      <pubDate>Tue, 17 Sep 2024 02:18:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Error-array-element-has-no-value/m-p/944189#M2323</guid>
      <dc:creator>norachanisara</dc:creator>
      <dc:date>2024-09-17T02:18:42Z</dc:date>
    </item>
    <item>
      <title>Re: Error: array element has no value</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Error-array-element-has-no-value/m-p/944241#M2326</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/469405"&gt;@norachanisara&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Dear Paige and Jackie,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you very much for fast response. Here is the log of when I run the code. Please do let me know if I'm not pasting the right thing. I am fairly new to SAS and the community.&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Please read carefully. I said: "If the problem occurs in a specific PROC, &lt;FONT color="#FF0000"&gt;just show us the log for that PROC&lt;/FONT&gt;."&lt;/P&gt;</description>
      <pubDate>Tue, 17 Sep 2024 09:50:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Error-array-element-has-no-value/m-p/944241#M2326</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-09-17T09:50:54Z</dc:date>
    </item>
    <item>
      <title>Re: Error: array element has no value</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Error-array-element-has-no-value/m-p/944286#M2328</link>
      <description>&lt;P&gt;That is another valid approach but is a bit error-prone.&amp;nbsp; For example, are the 44.159 and 44.15 supposed to be the same?&lt;/P&gt;</description>
      <pubDate>Tue, 17 Sep 2024 15:59:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Error-array-element-has-no-value/m-p/944286#M2328</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2024-09-17T15:59:19Z</dc:date>
    </item>
  </channel>
</rss>

