# Why do I get an “invalid subscript discarded” message when I display an AMPL parameter?

**URL:** <https://discuss.ampl.com/t/why-do-i-get-an-invalid-subscript-discarded-message-when-i-display-an-ampl-parameter/59>\
**Category:** FAQs\
**Tags:** sets-and-indexing\
**Created:** [December 15, 2021, 5:38pm UTC](https://discuss.ampl.com/t/why-do-i-get-an-invalid-subscript-discarded-message-when-i-display-an-ampl-parameter/59 "2021-12-15T17:38:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![megrobert](https://avatars.discourse-cdn.com/v4/letter/m/d07c76/32.png) [@megrobert](https://discuss.ampl.com/u/megrobert)\
**Post date:** [December 15, 2021, 5:38pm UTC](https://discuss.ampl.com/t/why-do-i-get-an-invalid-subscript-discarded-message-when-i-display-an-ampl-parameter/59/1 "2021-12-15T17:38:35Z")

</div>

Either a data table gave values for the parameter with incorrect subscripts, or the parameter’s indexing set changed, causing some previously valid subscripts to become invalid. For example, in the [diet.mod](https://ampl.com/BOOK/EXAMPLES/EXAMPLES2/diet.mod) + [diet.dat](https://ampl.com/BOOK/EXAMPLES/EXAMPLES2/diet.dat) example (Figures [2-1](https://ampl.com/BOOK/CHAPTERS/05-tut2.pdf#page=6) and [2-2](https://ampl.com/BOOK/CHAPTERS/05-tut2.pdf#page=7)) of the [AMPL book](https://ampl.com/resources/the-ampl-book/), values of parameter cost are supplied for all eight members of set `FOOD` :

```auto
ampl: display cost; 
cost [*] := 
BEEF 3.19 FISH 2.29 MCH 1.89 SPG 1.99 CHK 2.59 HAM 2.89 MTL 1.99 TUR 2.49 
;

```

If you remove the member `CHK` from `FOOD` , using for example a `let` command, then you get a message that `cost["CHK"]` has also been dropped from the data:

```auto
ampl: let FOOD := FOOD diff {"CHK"}; 
ampl: display cost; 
Error executing "display" command: 
error processing param cost: invalid subscript cost['CHK'] discarded. 
cost [*] := 
BEEF 3.19 HAM 2.89 MTL 1.99 TUR 2.49 FISH 2.29 MCH 1.89 SPG 1.99

```

Since `cost["CHK"]` has now been dropped, no further error message will appear if you type `display cost` again.

To avoid error messages of this sort, you can define a more flexible set structure for your model as shown in [dietflex.mod](https://discuss.ampl.com/uploads/short-url/tH0p6oCpCPodfyaLzELCyPhdO4l.mod) and [dietflex.dat](https://discuss.ampl.com/uploads/short-url/ne6ZXHmYZEI7GzDx4SUwBfD332q.dat). The auxiliary set `FOOD_DROP` defaults to empty, so that the problem is solved for all foods; but you can change `FOOD_DROP` to `{"CHK"}` to solve without member `CHK` :

```auto
ampl: model dietflex.mod; 
ampl: data dietflex.dat; 
ampl: option show_stats 1; 

ampl: solve; 
8 variables, all linear 
6 constraints, all linear; 47 nonzeros 
        5 inequality constraints
        1 range constraint
1 linear objective; 8 nonzeros. 

MINOS 5.51: optimal solution found. 
13 iterations, objective 118.0594032 

ampl: let FOOD_DROP := {"CHK"}; 

ampl: solve; 
7 variables, all linear 
6 constraints, all linear; 42 nonzeros 
	5 inequality constraints
	1 range constraint
1 linear objective; 7 nonzeros. 

MINOS 5.51: optimal solution found. 
3 iterations, objective 117.3218891

```

Changing `FOOD_DROP` does not affect the set `FOOD_ALL` , and consequently all of the subscripts in the data remain valid.
