Hello.
Not sure about what you're trying to do, but nothing wrong about the [ and $ char, and there's something wrong about your code.
When mixing dataset vars (prefix) with macro expressions that resolves to a char value you should enclose the expression in double quotes.
Another common mistake is not defining the maximum length of a new char var inside the datastep. SAS will do it for you, on assumption. In this case SAS is assuming that the first assignment to the prefix var (prefix="currency") will be its maximum allocated size, so prefix is defined in your example as a 8 char var. Keeping that in mind, the expression "[$€-1809]#,##0.00" will be truncated to "[$€-1809".
So,
data _null_;
if &port_id = 1 or &port_id = 26 then prefix="currency";
else if &port_id = 5 or &port_id = 49 or &port_id = 7 then prefix=%nrbquote([$€-1809]#,##0.00);
else if &port_id = 8 then prefix=%nrbquote([$$-409]#,##0.00);
call symput("prefix",%sysfunc(compress(prefix)));
run;
Should be:
data _null_;
length prefix $200; /* define prefix size */
if &port_id = 1 or &port_id = 26 then prefix="currency";
else if &port_id = 5 or &port_id = 49 or &port_id = 7 then prefix="[$€-1809]#,##0.00"; /* double quotes needed, no need for %nrbquote */
else if &port_id = 8 then prefix="[$$-409]#,##0.00"; /* same here */
call symput("prefix",compress(prefix)); /* no need for %sysfunc here */
run;
Is this what you're trying to do?
Greetings from Portugal.
Daniel Santos at
www.cgd.pt.