- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
hello team,
What is the difference between symputx and call symputx?
Respectfully,
blue&blue
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Great question. This is a perfect place for you to consult the documentation.
https://documentation.sas.com/doc/en/pgmmvacdc/9.4/mcrolref/p1fa0ay5pzr9yun1mvqxv8ipzd4d.htm
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
The documentation has it description of the differences.
Comparisons
CALL SYMPUTX is similar to CALL SYMPUT. Here are the differences.
-
CALL SYMPUTX does not write a note to the SAS log when the second argument is numeric. CALL SYMPUT, however, writes a note to the log stating that numeric values were converted to character values.
-
CALL SYMPUTX uses a field width of up to 32 characters when it converts a numeric second argument to a character value. CALL SYMPUT uses a field width of up to 12 characters.
-
CALL SYMPUTX left-justifies both arguments and trims trailing blanks. CALL SYMPUT does not left-justify the arguments, and trims trailing blanks from the first argument only. Leading blanks in the value of name cause an error.
-
CALL SYMPUTX enables you to specify the symbol table in which to store the macro variable, whereas CALL SYMPUT does not.
But the main thing to remember is you only ever want to use the old (very old) CALL SYMPUT() function if it is required that the macro variable contain leading and/or trailing space characters.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I think I wish CALL SYMPUTX would throw the note about converting numeric values to character. I think I also wish the CAT functions would throw that note. It's fine, I guess, that SAS added routines / functions that will do implicit conversions, but it does seem NOTE-worthy to me.
Next up: SAS Trivia Quiz hosted by SAS on Wednesday May 21.
Register now at https://www.basug.org/events.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
See the article "Does SYMPUT work in IML" for a discussion about some of the points that @Quentin and others mention. Quentin: Note that not all SAS procedures do an automatic conversion. It is primarily the DATA step that decided to "be helpful" by performing automatic conversions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
When a function's name ends with an 'x' it strips leading and trailing blanks. For example, cat('a',' b ') = 'a b ', while catx('a',' b ') = 'ab'. Similarly, call symput("var", " MWSUG ") puts " MWSUG " into macro variable var, while call symputx("var", " MWSUG ") strips the leading and trailing blanks, putting "MWSUG" into macro variable var. The 'x' functions did not become available until version 9. The older way to strip the blanks was to nest the input parameters in a strip() function, so something like cat('a', strip(' b ')) would be equivalent to catx('a', ' b ').
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@pink_poodle wrote:
(...) For example, cat('a',' b ') = 'a b ', while catx('a',' b ') = 'ab'. (...) something like cat('a', strip(' b ')) would be equivalent to catx('a', ' b ').
@pink_poodle: I think you mean cats, not catx.
catx('a',' b ') = 'b'
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
https://documentation.sas.com/doc/en/vdmmlcdc/1.0/lefunctionsref/n0p7wxtk0hvn83n1pveisbcp2ae9.htm
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I never had a theory for any 'meaning' for the x on the end of CALL SYMPUTX. I feel like they didn't want to call it CALL SYMPUT2, but they also sensibly couldn't change CALL SYMPUT without breaking legacy code, and then just decided to put an X on the end to give it a different name.
Next up: SAS Trivia Quiz hosted by SAS on Wednesday May 21.
Register now at https://www.basug.org/events.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
CATS concatenates the arguments; CATX uses the first argument as a delimiter between all the following arguments. Both functions remove leading and trailing blanks before concatenating.