<?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: %STR() vs. %NRSTR() in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/STR-vs-NRSTR/m-p/107177#M22323</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;dj,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Inside the %str and %nrstr functions, special characters require special handling.&amp;nbsp; You found one of them:&amp;nbsp; % should be referred to as %%.&amp;nbsp; However, others are in this category as well.&amp;nbsp; ( should be referred to as %(, and ) as %).&amp;nbsp; So technically, your original macro calls should have used:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;stratlab1=%str(FR%(++%)),&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, when the parentheses are balanced, you can often get away with omitting the % before them.&amp;nbsp; Once you added %, intending it to be a literal character, you actually changed the right parentheses by referring to it as %).&amp;nbsp; Now the parentheses appear to macro language to be unbalanced.&amp;nbsp; I consider it amazing that you actually figured out to add )))) to be able to continue processing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 29 Aug 2012 14:25:55 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2012-08-29T14:25:55Z</dc:date>
    <item>
      <title>%STR() vs. %NRSTR()</title>
      <link>https://communities.sas.com/t5/SAS-Programming/STR-vs-NRSTR/m-p/107175#M22321</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I was just recently exposed to %NRSTR, so I am not familiar enough to answer my own question.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I used to have a macro that would ask for two stratification labels (STRATLAB1 and STRATLAB2) as well as a group label (GROUPLAB).&amp;nbsp; My tratification labels used to be FR(++) and FR(+) with a group label being "FR(++) vs. FR(+)".&amp;nbsp; Our company has now changed the naming convention to be FR(100%) in place of FR(++) and FR(10-90%) in place of FR(+).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My macro call used to look like this (This is very simplified.&amp;nbsp; My actual macro actually receives up to 25 parameters.):&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;%&lt;STRONG&gt;&lt;EM&gt;efficacyreport&lt;/EM&gt;&lt;/STRONG&gt;(stratlab1=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: blue; font-family: 'Courier New';"&gt;%str&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;(FR(&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10pt; font-family: 'Courier New';"&gt;++&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;)), stratlab2=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: blue; font-family: 'Courier New';"&gt;%str&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;(FR(&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10pt; font-family: 'Courier New';"&gt;+&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;)), grouplab1=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: blue; font-family: 'Courier New';"&gt;%nrstr&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;(FR(&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10pt; font-family: 'Courier New';"&gt;++&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;) &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: teal; font-family: 'Courier New';"&gt;vs.&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt; &lt;STRONG&gt;&lt;EM&gt;FR&lt;/EM&gt;&lt;/STRONG&gt;(&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10pt; font-family: 'Courier New';"&gt;+&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;)));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now, I am trying to run it like this, which is giving me errors:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;%&lt;STRONG&gt;&lt;EM&gt;efficacyreport&lt;/EM&gt;&lt;/STRONG&gt;(stratlab1=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: blue; font-family: 'Courier New';"&gt;%nrstr&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;(FR(&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10pt; font-family: 'Courier New';"&gt;100&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;%)), stratlab2=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: blue; font-family: 'Courier New';"&gt;%nrstr&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;(FR(&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10pt; font-family: 'Courier New';"&gt;10&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;-&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10pt; font-family: 'Courier New';"&gt;90&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;%)), grouplab1=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: blue; font-family: 'Courier New';"&gt;%nrstr&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;(FR(&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10pt; font-family: 'Courier New';"&gt;100&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;%) &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: teal; font-family: 'Courier New';"&gt;vs.&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt; &lt;STRONG&gt;&lt;EM&gt;FR&lt;/EM&gt;&lt;/STRONG&gt;(&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10pt; font-family: 'Courier New';"&gt;10&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;-&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10pt; font-family: 'Courier New';"&gt;90&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;%)));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can someone tell me if I have a syntax error?&amp;nbsp; I assume it is the % within the %NRSTR that is causing the problem becuase when I call the macro, the SAS log will not do anything (no errors, no warnings, no notes), and I cannot run other code.&amp;nbsp; If I run ); four times, then it spits out errors:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #943634; font-size: 9pt; font-family: 'SAS Monospace';"&gt;ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant, a datetime constant,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #943634; font-size: 9pt; font-family: 'SAS Monospace';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a missing value, INPUT, PUT.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The code inside the macro that is causing this macro looks like this (nothing wrong syntactically):&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;data efficacy;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set &amp;amp;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: teal; font-family: 'Courier New';"&gt;efficacydata.&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; strata=&amp;amp;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: teal; font-family: 'Courier New';"&gt;strata.&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; survtime=&amp;amp;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: teal; font-family: 'Courier New';"&gt;survtime.&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; censorflag=&amp;amp;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: teal; font-family: 'Courier New';"&gt;censorflag.&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where &lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;&amp;amp;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: teal; font-family: 'Courier New';"&gt;efficacydata, &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;&amp;amp;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: teal; font-family: 'Courier New';"&gt;strata, &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;&amp;amp;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: teal; font-family: 'Courier New';"&gt;survtime, and &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;&amp;amp;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: teal; font-family: 'Courier New';"&gt;censorflag &lt;/SPAN&gt;are input parameters with the macro.&amp;nbsp; The error message has the semi-colons underlined with a 22, and then gives me the ERROR 22-322 message.&amp;nbsp; I am sure that is has something to do with my % signs within the %NRSTR function.&amp;nbsp; This is why I have to submit ); four times to close the macro call.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any thoughts?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Aug 2012 14:01:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/STR-vs-NRSTR/m-p/107175#M22321</guid>
      <dc:creator>djbateman</dc:creator>
      <dc:date>2012-08-29T14:01:03Z</dc:date>
    </item>
    <item>
      <title>Re: %STR() vs. %NRSTR()</title>
      <link>https://communities.sas.com/t5/SAS-Programming/STR-vs-NRSTR/m-p/107176#M22322</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Someone can correct me if I am wrong, but it looks like I have to have two % signs instead of one.&amp;nbsp; I did that, and the macro ran fine.&amp;nbsp; But can someone explain to me why that is?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Aug 2012 14:20:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/STR-vs-NRSTR/m-p/107176#M22322</guid>
      <dc:creator>djbateman</dc:creator>
      <dc:date>2012-08-29T14:20:17Z</dc:date>
    </item>
    <item>
      <title>Re: %STR() vs. %NRSTR()</title>
      <link>https://communities.sas.com/t5/SAS-Programming/STR-vs-NRSTR/m-p/107177#M22323</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;dj,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Inside the %str and %nrstr functions, special characters require special handling.&amp;nbsp; You found one of them:&amp;nbsp; % should be referred to as %%.&amp;nbsp; However, others are in this category as well.&amp;nbsp; ( should be referred to as %(, and ) as %).&amp;nbsp; So technically, your original macro calls should have used:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;stratlab1=%str(FR%(++%)),&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, when the parentheses are balanced, you can often get away with omitting the % before them.&amp;nbsp; Once you added %, intending it to be a literal character, you actually changed the right parentheses by referring to it as %).&amp;nbsp; Now the parentheses appear to macro language to be unbalanced.&amp;nbsp; I consider it amazing that you actually figured out to add )))) to be able to continue processing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Aug 2012 14:25:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/STR-vs-NRSTR/m-p/107177#M22323</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-08-29T14:25:55Z</dc:date>
    </item>
  </channel>
</rss>

