I'm having problems with getting the hang of using functions in SAS, the syntax is confusing.
I'm trying to get name without a date in the end. For example I have something like this: "MODEL_NAME_202101" and I want "MODEL_NAME".
I'm doing it like so.
%let model_ds =
%sysfunc(
substr(
%scan(&models_list, 12),
0,
%length(%scan(&models_list, 12)) - 7
)
);
%put &model_ds;
And only thing I get is a warring that tells me nothing about syntax errors I'm making.
WARNING: Argument 2 to function SUBSTR referenced by the %SYSFUNC or %QSYSFUNC macro function is out of range.
No idea how I'm supposed to nest function calls. Is every call required to have %sysfunc
before call, or nesting functions inside already called function inside %sysfunc
are syntax correct.
Would be nice if someone could reference me to explanation/documentation of this specific "feature",
Thanks
Rhythm is likely correct about the best solution for you - but the specific error:
WARNING: Argument 2 to function SUBSTR referenced by the %SYSFUNC or %QSYSFUNC macro function is out of range.
That's because of this:
substr(...,0,...)
That second argument is "what position to start from". SAS is 1-based, not 0-based (are you a python developer originally? This may be a bit challenging then!), so it needs to never be lower than 1.
substr(...,1,...)