<?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 Help With %NRSTR code in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Help-With-NRSTR-code/m-p/714346#M27282</link>
    <description>&lt;P&gt;I have the following code.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Testing1;
	input A $ B $ C $ D $;
	datalines;
a*$"B, $%\- D_D( A&amp;amp;5`
;
run;

proc transpose data=testing1 out=testing1;
	var A B C D;
run;

proc sql noprint;
	select Col1 into :VarNames
		separated by '|'
	from Testing1;
quit;

%PUT VarNames=%NRBQUOTE(&amp;amp;VarNames.);
%LET VNum=%SYSFUNC(CountW(%NRSTR(&amp;amp;VarNames.),|));
%PUT VNum=&amp;amp;VNum.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I am unable to get VNum to = 4.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;VarNames=a*$"B,|$%\-|D_D(|A&amp;amp;5`&lt;/P&gt;
&lt;P&gt;with | as a delimiter, there should be 4 words.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but VNum keeps coming out as 1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 26 Jan 2021 18:05:25 GMT</pubDate>
    <dc:creator>mcook</dc:creator>
    <dc:date>2021-01-26T18:05:25Z</dc:date>
    <item>
      <title>Help With %NRSTR code</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Help-With-NRSTR-code/m-p/714346#M27282</link>
      <description>&lt;P&gt;I have the following code.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Testing1;
	input A $ B $ C $ D $;
	datalines;
a*$"B, $%\- D_D( A&amp;amp;5`
;
run;

proc transpose data=testing1 out=testing1;
	var A B C D;
run;

proc sql noprint;
	select Col1 into :VarNames
		separated by '|'
	from Testing1;
quit;

%PUT VarNames=%NRBQUOTE(&amp;amp;VarNames.);
%LET VNum=%SYSFUNC(CountW(%NRSTR(&amp;amp;VarNames.),|));
%PUT VNum=&amp;amp;VNum.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I am unable to get VNum to = 4.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;VarNames=a*$"B,|$%\-|D_D(|A&amp;amp;5`&lt;/P&gt;
&lt;P&gt;with | as a delimiter, there should be 4 words.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but VNum keeps coming out as 1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jan 2021 18:05:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Help-With-NRSTR-code/m-p/714346#M27282</guid>
      <dc:creator>mcook</dc:creator>
      <dc:date>2021-01-26T18:05:25Z</dc:date>
    </item>
    <item>
      <title>Re: Help With %NRSTR code</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Help-With-NRSTR-code/m-p/714347#M27283</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%LET VNum=%SYSFUNC(CountW(%NRBQUOTE(&amp;amp;VarNames.),|));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;When working with a macro variable name, you want %NRBQUOTE and not %nrstr&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jan 2021 18:10:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Help-With-NRSTR-code/m-p/714347#M27283</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-01-26T18:10:55Z</dc:date>
    </item>
    <item>
      <title>Re: Help With %NRSTR code</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Help-With-NRSTR-code/m-p/714349#M27284</link>
      <description>&lt;P&gt;Bah.&amp;nbsp; I'd already tried NRBQUOTE and it didn't work.&amp;nbsp; It gave me a recursion error.&amp;nbsp; so i changed it to NRSTR.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But i just tried it again, copying what you wrote, and it worked perfectly.&amp;nbsp; Thank you.&lt;/P&gt;
&lt;P&gt;I must have had a syntax error I didn't notice.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jan 2021 18:13:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Help-With-NRSTR-code/m-p/714349#M27284</guid>
      <dc:creator>mcook</dc:creator>
      <dc:date>2021-01-26T18:13:14Z</dc:date>
    </item>
    <item>
      <title>Re: Help With %NRSTR code</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Help-With-NRSTR-code/m-p/714363#M27288</link>
      <description>&lt;P&gt;Part of the issue is the unbalanced quote.&lt;/P&gt;
&lt;P&gt;From the documentation of %STR and %NRSTR&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;DIV class="xis-eDocBody"&gt;
&lt;DIV class="xis-refDictEntry"&gt;
&lt;DIV class="xis-details"&gt;
&lt;DIV id="n1wgky5jdzns81n1kp3en9aephu7" class="xis-topicContent"&gt;
&lt;DIV id="n0u1p9hs7eg28en1opw1g7q2s0zb" class="xis-paragraph"&gt;They also mask the following characters when they occur in pairs and when they are not matched and are marked by a preceding &lt;CODE class="xis-codeDefaultStyle"&gt;%&lt;/CODE&gt;&lt;/DIV&gt;
&lt;DIV id="n05m6i39lcyb98n13o4byjahi8mh" class="xis-codeBlock"&gt;
&lt;PRE class="xis-code"&gt;' " ( )&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So since your example single quote does not appear in a pair you are getting the | characters after the " as one word.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Personally by the time I need to use NRSTR or similar I start looking very closely at the whole process. Macro quoting is pretty dangerous when things go unexpected.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jan 2021 18:47:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Help-With-NRSTR-code/m-p/714363#M27288</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-01-26T18:47:53Z</dc:date>
    </item>
    <item>
      <title>Re: Help With %NRSTR code</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Help-With-NRSTR-code/m-p/714378#M27293</link>
      <description>&lt;P&gt;Personally I find it much easier to just use %SUPERQ() to add quoting to a macro variable.&lt;/P&gt;
&lt;PRE&gt;50
51    %let varnames=%superq(varnames);
52    %LET VNum=%SYSFUNC(CountW(&amp;amp;VarNames,|));
53    %PUT VNum=&amp;amp;VNum.;
VNum=4
&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Jan 2021 19:15:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Help-With-NRSTR-code/m-p/714378#M27293</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-01-26T19:15:49Z</dc:date>
    </item>
  </channel>
</rss>

