Page 1 of 1

Efficient variable declaration on subranges

Posted: Tue Nov 21, 2023 9:01 am
by AurelienP
Good morning,
I have a question regarding declaration of variables with different definitions on different subranges.

Assuming we have a subscript family COUNTRY containing the following subscript elements: FRA, ITA, USA, CAN, with FRA and ITA contained in the subrange EU, whereas USA and CAN contained in the subrange NAM.

We want to define a variable VAR depending on COUNTRY.
Among the following suggestions, which one would work (or not), and which one would be the best way to go?
  1. VAR[EU] = x
    VAR[NAM] = y
  2. VAR[COUNTRY]:EXCEPT:[NAM] = x
    VAR[NAM] = y
  3. VAR[COUNTRY]= IF THEN ELSE(COUNTRY = EU, x, y)
  4. VAR[COUNTRY]= IF THEN ELSE(COUNTRY = FRA :OR: COUNTRY = ITA, x, y)
Thanks in advance!

Re: Efficient variable declaration on subranges

Posted: Tue Nov 21, 2023 9:07 am
by Administrator
All will work.

Personally, I would use option 1, I find that way to be the clearest, one equation for each subrange. I don't like using :EXCEPT: statements as it makes it just a little more difficult to figure out what equation is responsible for calculating something, especially if there are multiple :EXCEPT: statements.

Re: Efficient variable declaration on subranges

Posted: Tue Nov 21, 2023 9:08 am
by AurelienP
OK thanks. In terms of performance, no difference at all then?

Re: Efficient variable declaration on subranges

Posted: Tue Nov 21, 2023 9:49 am
by Administrator
No difference in terms of performance. I find it much clearer, but others could be different.