BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
SasStatistics
Pyrite | Level 9

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 


 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

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.

--
Paige Miller

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26

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.

--
Paige Miller
Peter_C
Rhodochrosite | Level 12
Original q "in general, how do I see what the default value of the optional parameter"
Usually the doc standards are good and the default is explained. Here it is just cross referenced
Astounding
PROC Star

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?

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1333 views
  • 9 likes
  • 4 in conversation