GAMS: how to limit elements of a set when defining constraints

I had this multiperiod problem in which one of the constraints should be build over all periods of time, except for the last one.
As I had P = {1,2,3,4,5} periods of time, it meant that this particular constraint existed for the subgroup P' = {1,2,3,4}, while other constraints considered the whole time horizon.

Simple thing, hah?

Then I'd found myself wasting a lot of time to figure out how to code it on GAMS, despite of the wide availability of GAMS material on-line.
In the end, it was actually simple:

You have to define a subset before stating the constraints, as follow:

//Define the set and its respective subset 
SET T PERIODS /T1,T2,T3,T4,T5/;
SET g(T);

//Limit the subset accordingly. In this case, ORD(T) refers to the relative position of an element in the set.
//Thus, ORD(T)<5 means that the new subset g(T) will contain the first 4 elements of set T, aka.(T1, T2, T3, T4).
g(T) = ORD(T)<5   ; 

//Declare the variables and parameters (ommited here)
//Declare the objective function (ommited here)

//Declare the constraints as usual. Only substitute the set by the appropriated subset, when needed.
  FLOW(J,K,g(T))..                SUM((I), X(I,J,K,T)) =E= SUM((I), X(J,I,K,T+1)) ;  

I tried other ways to sum it up, but none of them worked.

If there is another manner to do it, please let me know.

Python: How to iterate over the indexes of a variable in a 'for loop'

Somehow iterating over a multi-indexed dataframe can be tricky. I wanted to access a value related to an employee in the current and in the...