<?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 Weird nrquote behaviour in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Weird-nrquote-behaviour/m-p/408678#M99801</link>
    <description>&lt;P&gt;Consider this snippet:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let V = %nrquote(LONG TEXT);

%put "&amp;amp;V";    /* OK */
%put "&amp;amp;V"n;   /* WHAT?! */

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The output of the first put is:&lt;/P&gt;
&lt;PRE&gt;"LONG TEXT"&lt;/PRE&gt;
&lt;P&gt;which is correct.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The output of the second put is&lt;/P&gt;
&lt;PRE&gt;"&amp;#5;LONG TEXT&amp;#8;"n&lt;/PRE&gt;
&lt;P&gt;which contains some very weird characters at after and before the double quotes.&lt;/P&gt;
&lt;P&gt;I would expect to see the output of the second put as:&lt;/P&gt;
&lt;PRE&gt;"LONG TEXT"n&lt;/PRE&gt;
&lt;P&gt;What is happening?!?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need this to execute a data step:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WORK.&amp;amp;V;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;where the table is given as an input and the name may contain spaces.&lt;/P&gt;</description>
    <pubDate>Mon, 30 Oct 2017 14:15:18 GMT</pubDate>
    <dc:creator>Edoedoedo</dc:creator>
    <dc:date>2017-10-30T14:15:18Z</dc:date>
    <item>
      <title>Weird nrquote behaviour</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Weird-nrquote-behaviour/m-p/408678#M99801</link>
      <description>&lt;P&gt;Consider this snippet:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let V = %nrquote(LONG TEXT);

%put "&amp;amp;V";    /* OK */
%put "&amp;amp;V"n;   /* WHAT?! */

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The output of the first put is:&lt;/P&gt;
&lt;PRE&gt;"LONG TEXT"&lt;/PRE&gt;
&lt;P&gt;which is correct.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The output of the second put is&lt;/P&gt;
&lt;PRE&gt;"&amp;#5;LONG TEXT&amp;#8;"n&lt;/PRE&gt;
&lt;P&gt;which contains some very weird characters at after and before the double quotes.&lt;/P&gt;
&lt;P&gt;I would expect to see the output of the second put as:&lt;/P&gt;
&lt;PRE&gt;"LONG TEXT"n&lt;/PRE&gt;
&lt;P&gt;What is happening?!?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need this to execute a data step:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WORK.&amp;amp;V;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;where the table is given as an input and the name may contain spaces.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Oct 2017 14:15:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Weird-nrquote-behaviour/m-p/408678#M99801</guid>
      <dc:creator>Edoedoedo</dc:creator>
      <dc:date>2017-10-30T14:15:18Z</dc:date>
    </item>
    <item>
      <title>Re: Weird nrquote behaviour</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Weird-nrquote-behaviour/m-p/408687#M99804</link>
      <description>&lt;P&gt;These are artifacts of the macro quoting functions, which are later used by the macro processor while resolving/non-resolving.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This works:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let V = LONG TEXT;

data work."&amp;amp;v."n;
set sashelp.class;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Thou shalt not use non-standard names for SAS datasets. Unless you have a really strong masochistic tendency.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And if you have to use quoting functions to mask macro triggers(!) in dataset names, you're very far out in ga-ga land.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Oct 2017 14:24:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Weird-nrquote-behaviour/m-p/408687#M99804</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-30T14:24:43Z</dc:date>
    </item>
    <item>
      <title>Re: Weird nrquote behaviour</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Weird-nrquote-behaviour/m-p/408701#M99811</link>
      <description>&lt;P&gt;Truth is, I'm developing a job in Data Integration, and I let the user&amp;nbsp;to choose the&amp;nbsp;output table name in a text prompt.&lt;/P&gt;
&lt;P&gt;Looking at the job's generated code, I see that DI puts the prompt value in %nrquote. I don't need that, however so it is.&lt;/P&gt;
&lt;P&gt;Moreover, some legacy output tables have been created with spaces so I must make it work also in this case.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So: the user inserts in the prompt the output table name text. I configured DI to put this text into the macrovar &amp;amp;OUTPUT_TABLE.&lt;/P&gt;
&lt;P&gt;Suppose the user inserts &lt;U&gt;TABLE 1&lt;/U&gt;. I see in the DI autogenerated code this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let OUTPUT_TABLE = %nrquote(TABLE 1);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;just before my custom code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then when I try to use a datastep with this macrovar, neither&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data &amp;amp;OUTPUT_TABLE;
  set ...;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;nor&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data "&amp;amp;OUTPUT_TABLE"n;
  set ...;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;works.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried your code, it runs successfully however the table generated contains the weird characters in its name! That is, the table name is really:&lt;/P&gt;
&lt;PRE&gt;WORK.&amp;#5;LONG TEXT&amp;#8;&lt;/PRE&gt;
&lt;P&gt;What would you recommend me to do?&lt;/P&gt;</description>
      <pubDate>Mon, 30 Oct 2017 14:40:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Weird-nrquote-behaviour/m-p/408701#M99811</guid>
      <dc:creator>Edoedoedo</dc:creator>
      <dc:date>2017-10-30T14:40:11Z</dc:date>
    </item>
    <item>
      <title>Re: Weird nrquote behaviour</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Weird-nrquote-behaviour/m-p/408742#M99821</link>
      <description>&lt;P&gt;Spaces are not allowed inside data set names, e.g.:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;29   options validvarname=any;
30
31   data "Table 1"n;
32     set sashelp.class;
33   run;

ERROR: The value 'TABLE 1'n is not a valid SAS name.
NOTE: The SAS System stopped processing this step because of errors.
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your users don't know this, and you want to allow them to enter spaces, I think you'll have to fix the name for them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you don't need the macro quoting, you could %sysfunc(compress()) the data set name, e.g. :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;46   %let OUTPUT_TABLE = %nrquote(TABLE 1);
47   %let OUTPUT_TABLE = %sysfunc(compress(&amp;amp;Output_Table));
48
49   data &amp;amp;Output_Table;
50     set sashelp.class;
51   run;

NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: The data set WORK.TABLE1 has 19 observations and 5 variables.&lt;/PRE&gt;</description>
      <pubDate>Mon, 30 Oct 2017 15:26:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Weird-nrquote-behaviour/m-p/408742#M99821</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2017-10-30T15:26:36Z</dc:date>
    </item>
    <item>
      <title>Re: Weird nrquote behaviour</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Weird-nrquote-behaviour/m-p/408764#M99828</link>
      <description>&lt;P&gt;Spaces&amp;nbsp;&lt;STRONG&gt;are&lt;/STRONG&gt; allowed in member names when you set the &lt;A href="http://go.documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.2&amp;amp;docsetId=lesysoptsref&amp;amp;docsetTarget=n10nwm6blrcrtmn0zdcwyxlwxfjh.htm&amp;amp;locale=en" target="_self"&gt;VALIDMEMNAME option &lt;/A&gt;(new in 9.4).&amp;nbsp; But I agree with everyone who advises against it -- this option is more about preserving names when reading from other sources from other systems with their own crazy permissive rules.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Oct 2017 15:57:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Weird-nrquote-behaviour/m-p/408764#M99828</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2017-10-30T15:57:55Z</dc:date>
    </item>
    <item>
      <title>Re: Weird nrquote behaviour</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Weird-nrquote-behaviour/m-p/408772#M99831</link>
      <description>&lt;P&gt;Ahh, thanks for the correction, &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4"&gt;@ChrisHemedinger&lt;/a&gt;.&amp;nbsp; That's what I get for posting while listening to a conference call...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So for those who want to live dangerously, looks like you could set validmemname=extend, and then the only issue is you would need to %unquote() the value of the data set name, e.g.:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;89   %let OUTPUT_TABLE = %nrquote(TABLE 1);
90   options validmemname=extend;
91
92   %put &amp;gt;&amp;gt;&amp;amp;Output_Table&amp;lt;&amp;lt;;
&amp;gt;&amp;gt;TABLE 1&amp;lt;&amp;lt;
93
94   data "&amp;amp;OUTPUT_TABLE"n;
95     set sashelp.class;
96   run;

ERROR: Invalid physical name for library WORK.
NOTE: The SAS System stopped processing this step because of errors.

97
98
99   data "%unquote(&amp;amp;OUTPUT_TABLE)"n;
100    set sashelp.class;
101  run;

NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: The data set WORK.'TABLE 1'n has 19 observations and 5 variables.
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As long as you don't have any macro triggers in the name, might be acceptable.&amp;nbsp; For risk takers...&lt;/P&gt;</description>
      <pubDate>Mon, 30 Oct 2017 16:10:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Weird-nrquote-behaviour/m-p/408772#M99831</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2017-10-30T16:10:40Z</dc:date>
    </item>
    <item>
      <title>Re: Weird nrquote behaviour</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Weird-nrquote-behaviour/m-p/408781#M99834</link>
      <description>&lt;P&gt;If you want to use non-standard member names then set VALIDMEMNAME=EXTEND.&lt;/P&gt;
&lt;P&gt;If you want to convert user entered text to a name literal then use the NLITERAL() function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let OUTPUT_TABLE = %nrquote(TABLE 1);

%let output_table_x=%sysfunc(nliteral(%superq(output_table)));
 &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 30 Oct 2017 16:33:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Weird-nrquote-behaviour/m-p/408781#M99834</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-10-30T16:33:17Z</dc:date>
    </item>
  </channel>
</rss>

