sasoptpy.actions.put_item

put_item(*args, names=None)[source]

Prints the specified item values to the output log

Parameters
argssasoptpy.Expression, string

Arbitrary elements to be put into log

Variables, variable groups, and expressions can be printed to log

namesbool, optional

When set to True, prints the name of the arguments in the log

Examples

Regular operation:

>>> with so.Workspace('w') as w:
>>>     for i in for_loop(range(1, 3)):
>>>         for j in for_loop(['a', 'b']):
>>>             put_item(i, j)
>>> print(so.to_optmodel(w))
proc optmodel;
    for {o2 in 1..2} do;
        for {o5 in {'a','b'}} do;
            put o2 o5;
        end;
    end;
quit;

Print with names:

>>> with so.Workspace('w') as w:
>>>     x = so.VariableGroup(6, name='x', lb=0)
>>>     so.Objective(
>>>         so.expr_sum(x[i] for i in range(6)), name='z', sense=so.MIN)
>>>     a1 = so.Constraint(x[1] + x[2] + x[3] <= 4, name='a1')
>>>     for i in cofor_loop(so.exp_range(3, 6)):
>>>         fix(x[1], i)
>>>         solve()
>>>         put_item(i, x[1], so.Symbol('_solution_status_'), names=True)
proc optmodel;
    var x {{0,1,2,3,4,5}} >= 0;
    min z = x[0] + x[1] + x[2] + x[3] + x[4] + x[5];
    con a1 : x[1] + x[2] + x[3] <= 4;
    cofor {o13 in 3..5} do;
        fix x[1]=o13;
        solve;
        put o13= x[1]= _solution_status_=;
    end;
quit;