sasoptpy.actions.substring

substring(main_string, first_pos, last_pos)[source]

Gets the substring of the specified positions

Parameters
main_stringsasoptpy.abstract.Parameter or string

Main string

first_posinteger

First position of the substring, starting from 1

last_posinteger

Last position of the substring

Examples

>>> with so.Workspace('w') as w:
>>>     p = so.Parameter(name='p', value='random_string', ptype=so.STR)
>>>     r = so.Parameter(name='r', value=substring(p, 1, 6), ptype=so.STR)
>>>     put_item(r)
>>> print(so.to_optmodel(w))
proc optmodel;
    str p = 'random_string';
    str r = substr(p, 1, 6);
    put r;
quit;