# Trouble creating solution table and writing to Excel

**URL:** <https://discuss.ampl.com/t/trouble-creating-solution-table-and-writing-to-excel/1049>\
**Category:** Support\
**Tags:** displays-results, errors-and-messages\
**Created:** [April 13, 2024, 7:48pm UTC](https://discuss.ampl.com/t/trouble-creating-solution-table-and-writing-to-excel/1049 "2024-04-13T19:48:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abendrot47](https://avatars.discourse-cdn.com/v4/letter/a/46a35a/32.png) [@Abendrot47](https://discuss.ampl.com/u/Abendrot47)\
**Post date:** [April 13, 2024, 7:48pm UTC](https://discuss.ampl.com/t/trouble-creating-solution-table-and-writing-to-excel/1049/1 "2024-04-13T19:48:08Z")

</div>

```auto
set SURGERY; 
set ROOM;

param tour > 0 integer;

var Assign{SURGERY, ROOM, 1..tour} binary;

table assignment OUT "amplxl" "3D" "sol.xlsx":
    {SURGERY, ROOM, 1..tour} -> [s ~ SURGERY, r ~ ROOM, t~TOUR], Assign[s,r,t];

write table assignment;

```

* * *

I am getting the following error for the write table line:

```auto
error processing var Assign[...]:
	no data for set SURGERY

```

---

<div class="post-metadata">

**Author:** ![4er](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.ampl.com/4er/32/530_2.png) [@4er](https://discuss.ampl.com/u/4er)\
**Post date:** [April 16, 2024, 3:45pm UTC](https://discuss.ampl.com/t/trouble-creating-solution-table-and-writing-to-excel/1049/2 "2024-04-16T15:45:45Z")

</div>

You show here only the beginning of an AMPL model:

```auto
set SURGERY; 
set ROOM;

param tour > 0 integer;

var Assign{SURGERY, ROOM, 1..tour} binary;

```

Before you can use `write` `table` to send the values of the variables to a spreadsheet, you need to define an objective function (using a `minimize` or `maximize` statement) and constraints (using `subject` `to` statements); then you need to read data for `SURGERY`, `ROOM`, and `tour`; and finally you need to set a solver, and invoke AMPL’s `solve` command to get optimal values for the `Assign` variables.

In particular, if you have not read data for the `SURGERY` set, you will get the “no data for set SURGERY” message when you try to execute `write` `table`.

If you are defining a complete model and are doing all of the steps described above, but you are still getting the “no data” message, then to get more help, reply with all of your files attached.
