<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Reserved characters in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reserved-characters/m-p/21971#M3560</link>
    <description>Hello,&lt;BR /&gt;
&lt;BR /&gt;
Sorry, I've just focused on the first datastep. You should use double quotes for the resolved value of the macro var on your last datastep.&lt;BR /&gt;
&lt;BR /&gt;
data _null_;&lt;BR /&gt;
call symput("loc","&amp;amp;prefix"); /* &amp;amp;prefix in double quotes */&lt;BR /&gt;
call symput("GBP","currency");&lt;BR /&gt;
call symput("num","###,###,###");&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Greetings from Portugal.&lt;BR /&gt;
&lt;BR /&gt;
Daniel Santos at &lt;A href="http://www.cgd.pt" target="_blank"&gt;www.cgd.pt&lt;/A&gt;.</description>
    <pubDate>Wed, 22 Apr 2009 16:39:48 GMT</pubDate>
    <dc:creator>DanielSantos</dc:creator>
    <dc:date>2009-04-22T16:39:48Z</dc:date>
    <item>
      <title>Reserved characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reserved-characters/m-p/21966#M3555</link>
      <description>Hiya&lt;BR /&gt;
&lt;BR /&gt;
I am trying to use &lt;B&gt;tagattr&lt;/B&gt; to apply formats to currency in a report I am creating. The problem is that I am using a macro to switch currencies which means that I have to put the Excel formats into a macro variable.&lt;BR /&gt;
&lt;BR /&gt;
The format strings are &lt;B&gt;[$€-1809]#,##0.00&lt;/B&gt; and &lt;B&gt;[$$-409]#,##0.00&lt;/B&gt; but SAS just gives me an error as it does not like the &lt;B&gt;[&lt;/B&gt; or &lt;B&gt;$&lt;/B&gt;, or the use of &lt;B&gt;%sysfunc&lt;/B&gt;. I am using &lt;B&gt;call symput&lt;/B&gt; to do this. I have tried to put the formats into a variable using &lt;B&gt;%let&lt;/B&gt; before using the &lt;B&gt;call symput&lt;/B&gt; but this does not help.&lt;BR /&gt;
&lt;BR /&gt;
I have searched the forums but cannot find anything related to special characters. I have tried using &lt;B&gt;%nrbquotes&lt;/B&gt;. My code is below.&lt;BR /&gt;
&lt;BR /&gt;
&lt;I&gt;%macro local_curr(port_id=);&lt;BR /&gt;
 &lt;BR /&gt;
	data _null_;&lt;BR /&gt;
		if &amp;amp;port_id = 1 or &amp;amp;port_id = 26 then prefix="currency";&lt;BR /&gt;
		else if &amp;amp;port_id = 5 or &amp;amp;port_id = 49 or &amp;amp;port_id = 7 then prefix=%nrbquote([$€-1809]#,##0.00);&lt;BR /&gt;
		else if &amp;amp;port_id = 8 then prefix=%nrbquote([$$-409]#,##0.00);&lt;BR /&gt;
		call symput("prefix",%sysfunc(compress(prefix)));&lt;BR /&gt;
	run;&lt;BR /&gt;
&lt;BR /&gt;
	%put Local Currency is &amp;amp;prefix;&lt;BR /&gt;
&lt;BR /&gt;
	data _null_;&lt;BR /&gt;
		call symput("loc",%sysfunc(compress(&amp;amp;prefix)));&lt;BR /&gt;
		call symput("GBP",%sysfunc(compress("currency")));&lt;BR /&gt;
		call symput("num",%sysfunc(compress("###,###,###")));&lt;BR /&gt;
	run;&lt;BR /&gt;
&lt;BR /&gt;
	%put local is &amp;amp;loc, GBP is &amp;amp;GBP and number is &amp;amp;num;&lt;BR /&gt;
&lt;BR /&gt;
%mend local_curr;&lt;BR /&gt;
%local_curr (port_id=1);&lt;BR /&gt;
%local_curr (port_id=7);&lt;BR /&gt;
%local_curr (port_id=8);&lt;/I&gt;</description>
      <pubDate>Wed, 22 Apr 2009 10:35:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reserved-characters/m-p/21966#M3555</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-04-22T10:35:22Z</dc:date>
    </item>
    <item>
      <title>Re: Reserved characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reserved-characters/m-p/21967#M3556</link>
      <description>Hello.&lt;BR /&gt;
&lt;BR /&gt;
Not sure about what you're trying to do, but nothing wrong about the [ and $ char, and there's something wrong about your code.&lt;BR /&gt;
&lt;BR /&gt;
When mixing dataset vars (prefix) with macro expressions that resolves to a char value you should enclose the expression in double quotes.&lt;BR /&gt;
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".&lt;BR /&gt;
&lt;BR /&gt;
So, &lt;BR /&gt;
&lt;BR /&gt;
data _null_;&lt;BR /&gt;
if &amp;amp;port_id = 1 or &amp;amp;port_id = 26 then prefix="currency";&lt;BR /&gt;
else if &amp;amp;port_id = 5 or &amp;amp;port_id = 49 or &amp;amp;port_id = 7 then prefix=%nrbquote([$€-1809]#,##0.00);&lt;BR /&gt;
else if &amp;amp;port_id = 8 then prefix=%nrbquote([$$-409]#,##0.00);&lt;BR /&gt;
call symput("prefix",%sysfunc(compress(prefix)));&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Should be:&lt;BR /&gt;
&lt;BR /&gt;
data _null_;&lt;BR /&gt;
length prefix $200; /* define prefix size */&lt;BR /&gt;
if &amp;amp;port_id = 1 or &amp;amp;port_id = 26 then prefix="currency";&lt;BR /&gt;
else if &amp;amp;port_id = 5 or &amp;amp;port_id = 49 or &amp;amp;port_id = 7 then prefix="[$€-1809]#,##0.00";  /* double quotes needed, no need for %nrbquote */&lt;BR /&gt;
else if &amp;amp;port_id = 8 then prefix="[$$-409]#,##0.00"; /* same here */&lt;BR /&gt;
call symput("prefix",compress(prefix)); /* no need for %sysfunc here */&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Is this what you're trying to do?&lt;BR /&gt;
&lt;BR /&gt;
Greetings from Portugal.&lt;BR /&gt;
&lt;BR /&gt;
Daniel Santos at &lt;A href="http://www.cgd.pt" target="_blank"&gt;www.cgd.pt&lt;/A&gt;.</description>
      <pubDate>Wed, 22 Apr 2009 10:51:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reserved-characters/m-p/21967#M3556</guid>
      <dc:creator>DanielSantos</dc:creator>
      <dc:date>2009-04-22T10:51:43Z</dc:date>
    </item>
    <item>
      <title>Re: Reserved characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reserved-characters/m-p/21968#M3557</link>
      <description>I would suggest a format.  If you want to resolve it in code use &lt;BR /&gt;
&lt;BR /&gt;
%sysfunc(putN(24,portid))&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
proc format;&lt;BR /&gt;
   value portid&lt;BR /&gt;
      1,26     = 'currency'&lt;BR /&gt;
      5,7,49   = '[$€-1809]#,##0.00'&lt;BR /&gt;
      8        = '[$$-409]#,##0.00'&lt;BR /&gt;
      ;&lt;BR /&gt;
   run;&lt;BR /&gt;
&lt;BR /&gt;
data _null_;&lt;BR /&gt;
   Put 'NOTE: PORTID formatted' @;&lt;BR /&gt;
   do portid = 1,26,5,7,49,8;&lt;BR /&gt;
      put (portid portid) (/ 'NOTE- ' 3. +2  :portid.) @;&lt;BR /&gt;
      end;&lt;BR /&gt;
   run;&lt;BR /&gt;
%let portid = 26;&lt;BR /&gt;
%put NOTE: PORTID &amp;amp;portid is %sysfunc(putN(&amp;amp;portid,portid)); &lt;BR /&gt;
[/pre]</description>
      <pubDate>Wed, 22 Apr 2009 11:28:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reserved-characters/m-p/21968#M3557</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2009-04-22T11:28:36Z</dc:date>
    </item>
    <item>
      <title>Re: Reserved characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reserved-characters/m-p/21969#M3558</link>
      <description>Thanks for the answers guys.&lt;BR /&gt;
&lt;BR /&gt;
data _null_: When you put numbers through to Excel they must be unformatted or else Excel gets confused and makes a mess. You use &lt;B&gt;style={tagattr="format:currency"}&lt;/B&gt; to tell Excel how to format the data once it is there.&lt;BR /&gt;
&lt;BR /&gt;
Daniel: I have swapped your code for mine which has resolved one of the problems but I am still getting an error in my log, as below.&lt;BR /&gt;
&lt;BR /&gt;
&lt;I&gt;99   %macro local_curr(port_id=);&lt;BR /&gt;
100&lt;BR /&gt;
101      data _null_;&lt;BR /&gt;
102          length prefix $200; /* define prefix size */&lt;BR /&gt;
103          if &amp;amp;port_id = 1 or &amp;amp;port_id = 26 then prefix="currency";&lt;BR /&gt;
104          else if &amp;amp;port_id = 5 or &amp;amp;port_id = 49 or &amp;amp;port_id = 7 then&lt;BR /&gt;
104! prefix="[$€-1809]#,##0.00";&lt;BR /&gt;
105          /* double quotes needed, no need for %nrbquote */&lt;BR /&gt;
106          else if &amp;amp;port_id = 8 then prefix="[$$-409]#,##0.00"; /* same here */&lt;BR /&gt;
107          call symput("prefix",compress(prefix)); /* no need for %sysfunc here */&lt;BR /&gt;
108      run;&lt;BR /&gt;
109&lt;BR /&gt;
110      %put Local Currency is &amp;amp;prefix;&lt;BR /&gt;
111&lt;BR /&gt;
112      data _null_;&lt;BR /&gt;
113          call symput("loc",&amp;amp;prefix);&lt;BR /&gt;
114          call symput("GBP","currency");&lt;BR /&gt;
115          call symput("num","###,###,###");&lt;BR /&gt;
116      run;&lt;BR /&gt;
117&lt;BR /&gt;
118      %put local is &amp;amp;loc, GBP is &amp;amp;GBP and number is &amp;amp;num;&lt;BR /&gt;
119&lt;BR /&gt;
120  %mend local_curr;&lt;BR /&gt;
121  %local_curr (port_id=1);&lt;BR /&gt;
&lt;BR /&gt;
NOTE: DATA statement used (Total process time):&lt;BR /&gt;
      real time           0.01 seconds&lt;BR /&gt;
      cpu time            0.01 seconds&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Local Currency is currency&lt;BR /&gt;
&lt;BR /&gt;
NOTE: Numeric values have been converted to character values at the places given by:&lt;BR /&gt;
      (Line):(Column).&lt;BR /&gt;
      1:1&lt;BR /&gt;
NOTE: DATA statement used (Total process time):&lt;BR /&gt;
      real time           0.00 seconds&lt;BR /&gt;
      cpu time            0.00 seconds&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
local is            ., GBP is currency and number is ###,###,###&lt;BR /&gt;
122  %local_curr (port_id=7);&lt;BR /&gt;
&lt;BR /&gt;
NOTE: DATA statement used (Total process time):&lt;BR /&gt;
      real time           0.00 seconds&lt;BR /&gt;
      cpu time            0.00 seconds&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Local Currency is [$€-1809]#,##0.00&lt;BR /&gt;
&lt;BR /&gt;
NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;
NOTE: DATA statement used (Total process time):&lt;BR /&gt;
      real time           0.00 seconds&lt;BR /&gt;
      cpu time            0.00 seconds&lt;BR /&gt;
&lt;BR /&gt;
NOTE: Line generated by the macro variable "PREFIX".&lt;BR /&gt;
  [$€-1809]#,##0.00&lt;BR /&gt;
     -&lt;BR /&gt;
     386&lt;BR /&gt;
     76&lt;BR /&gt;
      -&lt;BR /&gt;
      200&lt;BR /&gt;
&lt;BR /&gt;
ERROR 386-185: Expecting an arithmetic expression.&lt;BR /&gt;
&lt;BR /&gt;
ERROR 76-322: Syntax error, statement will be ignored.&lt;BR /&gt;
&lt;BR /&gt;
ERROR 200-322: The symbol is not recognized and will be ignored.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
WARNING: Apparent symbolic reference LOC not resolved.&lt;BR /&gt;
WARNING: Apparent symbolic reference GBP not resolved.&lt;BR /&gt;
WARNING: Apparent symbolic reference NUM not resolved.&lt;BR /&gt;
local is &amp;amp;loc, GBP is &amp;amp;GBP and number is &amp;amp;num&lt;BR /&gt;
123  %local_curr (port_id=8);&lt;BR /&gt;
&lt;BR /&gt;
NOTE: DATA statement used (Total process time):&lt;BR /&gt;
      real time           0.00 seconds&lt;BR /&gt;
      cpu time            0.00 seconds&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Local Currency is [$$-409]#,##0.00&lt;BR /&gt;
&lt;BR /&gt;
NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;
NOTE: DATA statement used (Total process time):&lt;BR /&gt;
      real time           0.00 seconds&lt;BR /&gt;
      cpu time            0.00 seconds&lt;BR /&gt;
&lt;BR /&gt;
NOTE: Line generated by the macro variable "PREFIX".&lt;BR /&gt;
   [$$-409]#,##0.00&lt;BR /&gt;
     -&lt;BR /&gt;
     386&lt;BR /&gt;
     76&lt;BR /&gt;
      -&lt;BR /&gt;
      200&lt;BR /&gt;
&lt;BR /&gt;
ERROR 386-185: Expecting an arithmetic expression.&lt;BR /&gt;
&lt;BR /&gt;
ERROR 76-322: Syntax error, statement will be ignored.&lt;BR /&gt;
&lt;BR /&gt;
ERROR 200-322: The symbol is not recognized and will be ignored.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
WARNING: Apparent symbolic reference LOC not resolved.&lt;BR /&gt;
WARNING: Apparent symbolic reference GBP not resolved.&lt;BR /&gt;
WARNING: Apparent symbolic reference NUM not resolved.&lt;BR /&gt;
local is &amp;amp;loc, GBP is &amp;amp;GBP and number is &amp;amp;num&lt;BR /&gt;
&lt;/I&gt;</description>
      <pubDate>Wed, 22 Apr 2009 11:55:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reserved-characters/m-p/21969#M3558</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-04-22T11:55:47Z</dc:date>
    </item>
    <item>
      <title>Re: Reserved characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reserved-characters/m-p/21970#M3559</link>
      <description>&amp;gt; data _null_: When you put numbers through to Excel&lt;BR /&gt;
&amp;gt; they must be unformatted or else Excel gets confused&lt;BR /&gt;
&amp;gt; and makes a mess. You use&lt;BR /&gt;
&amp;gt; &lt;B&gt;style={tagattr="format:currency"}&lt;/B&gt; to tell&lt;BR /&gt;
&amp;gt; Excel how to format the data once it is there.&lt;BR /&gt;
&lt;BR /&gt;
I understand that Scoob.  My suggestion was to replace the data step that creates the macro variables you don't need and simply use %sysfunc(putN(...).  Value label formats provide a nice simple table lookup feature.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
style={tagattr="format:%sysfunc(putN(&amp;amp;port_id,portid))"}&lt;BR /&gt;
[/pre]</description>
      <pubDate>Wed, 22 Apr 2009 13:13:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reserved-characters/m-p/21970#M3559</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2009-04-22T13:13:21Z</dc:date>
    </item>
    <item>
      <title>Re: Reserved characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reserved-characters/m-p/21971#M3560</link>
      <description>Hello,&lt;BR /&gt;
&lt;BR /&gt;
Sorry, I've just focused on the first datastep. You should use double quotes for the resolved value of the macro var on your last datastep.&lt;BR /&gt;
&lt;BR /&gt;
data _null_;&lt;BR /&gt;
call symput("loc","&amp;amp;prefix"); /* &amp;amp;prefix in double quotes */&lt;BR /&gt;
call symput("GBP","currency");&lt;BR /&gt;
call symput("num","###,###,###");&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Greetings from Portugal.&lt;BR /&gt;
&lt;BR /&gt;
Daniel Santos at &lt;A href="http://www.cgd.pt" target="_blank"&gt;www.cgd.pt&lt;/A&gt;.</description>
      <pubDate>Wed, 22 Apr 2009 16:39:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reserved-characters/m-p/21971#M3560</guid>
      <dc:creator>DanielSantos</dc:creator>
      <dc:date>2009-04-22T16:39:48Z</dc:date>
    </item>
    <item>
      <title>Re: Reserved characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reserved-characters/m-p/21972#M3561</link>
      <description>Thanks Daniel.</description>
      <pubDate>Thu, 23 Apr 2009 07:21:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reserved-characters/m-p/21972#M3561</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-04-23T07:21:36Z</dc:date>
    </item>
  </channel>
</rss>

