In the CALL SYMNPUTX routine, the syntax is of the form:
CALL SYMPUTX (macro-variable, value <, symbol-table>);
By <> I know there is an optional paramater. But in general, how do I see what the default value of the optional parameter is?
For instance, reading the documentation, I could not see it:
https://documentation.sas.com/doc/en/vdmmlcdc/8.1/mcrolref/p1fa0ay5pzr9yun1mvqxv8ipzd4d.htm
The three possible values for the optional argument seem to me to be spelled out clearly at that link. The default is also stated there:
If you omit symbol-table, or if symbol-table is blank, CALL SYMPUTX stores the macro variable in the same symbol table as does the CALL SYMPUT routine.
The three possible values for the optional argument seem to me to be spelled out clearly at that link. The default is also stated there:
If you omit symbol-table, or if symbol-table is blank, CALL SYMPUTX stores the macro variable in the same symbol table as does the CALL SYMPUT routine.
You're actually entering a complex realm with that question. You may not be happy that you asked.
For simplicity sake, let's assume that you are running a macro, and don't have a situation where macros are calling other macros. So the only two choices are the local symbol table and the global symbol table in this simplified scenario.
First step: see if that macro variable (first parameter in SYMPUTX) already exists. Check the local symbol table first. If the variable already exists there, replace it with the result from SYMPUTX. If not, check the global symbol table. If it exists there, replace it with the value from SYMPUTX.
Second step: if the macro variable does not already exist in any existing symbol table, create it. Where? The answer depends on whether the local symbol table has any macro variables in it already. If it does, add the SYMPUTX variable to the local symbol table. If not, add it to the global symbol table.
Technically, the reason for this complex behavior is that there is no such thing as an empty symbol table. The local symbol table doesn't really get created until SAS needs to place a macro variable within it. So SYMPUTX doesn't have a choice if the local symbol table is empty because that actually means the local table has not been created yet.
Do you want to expand this to the situation where macros are calling macros, so you have the possibility of each macro having its own local symbol table?
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: