How to mask a comma in sas macro?

How to mask a comma in sas macro?

Another way to mask a comma in a macro parameter value is to simply use parenthesis around the value. The problem is that the parenthesis become part of the value. Since you have the value in symbol X another way would be to pass the symbol name and let the macro resolve it using the proper “protection”.

How do you use Bquote in SAS?

Examples Using %BQUOTE

  1. %if %bquote(&state)=%str(OR) %then %put Oregon Dept. of Revenue;
  2. data test; store=”Susan’s Office Supplies”; call symput(‘s’,store); run; %macro readit; %if %bquote(&s) ne %then %put *** valid ***; %else %put *** null value ***; %mend readit; %readit.
  3. Susan’s Office Supplies.

How do I scan a function in SAS?

The most basic use of the SCAN function requires only two arguments. After specifying SCAN and an open parenthesis, the first part of the function is to specify the character string that you are planning to select words from. This can be either a variable or an explicit character string.

How to mask a comma in a macro variable?

When you assign a comma-delimited list as a value to a macro variable, we want to mask commas within the resolved value during execution. Any of the execution time macro quoting functions will mask comma. Again, in case of multiple possibilities I would use the shortest one – %QUOTE ().

Can you hide a comma delimited value in a macro?

Even if you “hide” your comma-delimited value within a macro variable, it still won’t do any good since the macro variable gets resolved during macro compilation before being passed on to a macro or macro function for execution. You will still get the same ERROR: ERROR: Macro function %SCAN has too many arguments.

Why do we use commas as parameter separators in SAS?

treating each comma as a parameter separator. All this confusion happens because SAS functions’ arguments and SAS macros’ parameters use commas as their separators, while resolved macro variables introduce their own values’ comma delimiters into the functions/macros constructs’ picture, thus wreaking havoc on your SAS program.

How to define a macro that takes multiple arguments?

First, you can define a macro that takes multiple arguments: if you do that you may find that you end up defining more macros to handle more arguments. if you do that you may find that the extra parentheses screw up the syntax of the result. #include “p99/p99.h” #define FOO (…)