<?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: Why are two datasets created here instead of 1 ? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Why-are-two-datasets-created-here-instead-of-1/m-p/824390#M325582</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19879"&gt;@Quentin&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Your expectation is correct. It's a small bug that has been around for a long time that sometimes invisible quoting characters can cause problems for the compiler when SAS fails to automagically remove them. As Tom showed, in those cases explicitly %unquoting() the value is usually a solution.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;But not using %str() in the first place also eliminates the problem. Since &amp;amp;a1 is going to be part of a data set name, there's no need for %str() at all, there cannot be special characters in the data set name that %str() has to mask.&lt;/P&gt;</description>
    <pubDate>Wed, 20 Jul 2022 15:56:47 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-07-20T15:56:47Z</dc:date>
    <item>
      <title>Why are two datasets created here instead of 1 ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-are-two-datasets-created-here-instead-of-1/m-p/824357#M325557</link>
      <description>&lt;PRE&gt;&lt;CODE class=""&gt;%macro nmtest(a1=);

data class_&amp;amp;a1.;
   set sashelp.class;
run;

%mend nmtest;
%nmtest(a1=%str(bb));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 20 Jul 2022 13:46:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-are-two-datasets-created-here-instead-of-1/m-p/824357#M325557</guid>
      <dc:creator>Gemie</dc:creator>
      <dc:date>2022-07-20T13:46:24Z</dc:date>
    </item>
    <item>
      <title>Re: Why are two datasets created here instead of 1 ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-are-two-datasets-created-here-instead-of-1/m-p/824359#M325559</link>
      <description>&lt;P&gt;Your use of %str() is not needed here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro nmtest(a1=);
data class_&amp;amp;a1.;
   set sashelp.class;
run;

%mend nmtest;
%nmtest(a1=bb);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This produces only one data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you turn on macro debugging ... via this command&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options mlogic;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and then re-run your code, you will see in the log that &amp;amp;a1 has additional characters introduced by the unnecessary %str( )&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;118   options mlogic;
119   %macro nmtest(a1=);
120   data class_&amp;amp;a1.;
121      set sashelp.class;
122   run;
123
124   %mend nmtest;
125   %nmtest(a1=%str(bb))
MLOGIC(NMTEST):  Beginning execution.
&lt;FONT color="#FF0000"&gt;MLOGIC(NMTEST):  Parameter A1 has value &amp;#1;bb&amp;#2;&lt;/FONT&gt;
SYMBOLGEN:  Macro variable A1 resolves to bb
SYMBOLGEN:  Some characters in the above value which were subject to macro quoting have been unquoted for printing.
MPRINT(NMTEST):   data class_bb;
MPRINT(NMTEST):   set sashelp.class;
MPRINT(NMTEST):   run;
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;&amp;nbsp;might be able to explain in more detail&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jul 2022 14:08:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-are-two-datasets-created-here-instead-of-1/m-p/824359#M325559</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-07-20T14:08:50Z</dc:date>
    </item>
    <item>
      <title>Re: Why are two datasets created here instead of 1 ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-are-two-datasets-created-here-instead-of-1/m-p/824362#M325562</link>
      <description>&lt;P&gt;Thanks. I was only expecting class_bb to be generated and not class_ .&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jul 2022 14:06:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-are-two-datasets-created-here-instead-of-1/m-p/824362#M325562</guid>
      <dc:creator>Gemie</dc:creator>
      <dc:date>2022-07-20T14:06:03Z</dc:date>
    </item>
    <item>
      <title>Re: Why are two datasets created here instead of 1 ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-are-two-datasets-created-here-instead-of-1/m-p/824381#M325578</link>
      <description>&lt;P&gt;The %str function inserts a special macro token wich causes the dataset name to appear as two names for the data step compiler.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jul 2022 15:34:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-are-two-datasets-created-here-instead-of-1/m-p/824381#M325578</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-07-20T15:34:23Z</dc:date>
    </item>
    <item>
      <title>Re: Why are two datasets created here instead of 1 ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-are-two-datasets-created-here-instead-of-1/m-p/824382#M325579</link>
      <description>&lt;P&gt;The macro quoting is confusing the parser.&amp;nbsp; The macro quoting on the macro variable causes the macro processor to see that as two tokens which causes the SAS processing to also see it as two.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can remove the quoting using %UNQUOTE() macro function.&lt;/P&gt;
&lt;PRE&gt;248  %macro nmtest(a1=);
249
250  data %unquote(class_&amp;amp;a1.);
251     set sashelp.class;
252  run;
253
254  %mend nmtest;
255  options mprint;
256  %nmtest(a1=%str(bb));
MPRINT(NMTEST):   data class_bb;
MPRINT(NMTEST):   set sashelp.class;
MPRINT(NMTEST):   run;

NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: The data set WORK.CLASS_BB has 19 observations and 5 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jul 2022 15:44:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-are-two-datasets-created-here-instead-of-1/m-p/824382#M325579</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-07-20T15:44:12Z</dc:date>
    </item>
    <item>
      <title>Re: Why are two datasets created here instead of 1 ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-are-two-datasets-created-here-instead-of-1/m-p/824384#M325580</link>
      <description>Your expectation is correct.  It's a small bug that has been around for a long time that sometimes invisible quoting characters can cause problems for the compiler when SAS fails to automagically remove them.  As Tom showed, in those cases explicitly %unquoting() the value is usually a solution.</description>
      <pubDate>Wed, 20 Jul 2022 15:47:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-are-two-datasets-created-here-instead-of-1/m-p/824384#M325580</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2022-07-20T15:47:23Z</dc:date>
    </item>
    <item>
      <title>Re: Why are two datasets created here instead of 1 ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-are-two-datasets-created-here-instead-of-1/m-p/824390#M325582</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19879"&gt;@Quentin&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Your expectation is correct. It's a small bug that has been around for a long time that sometimes invisible quoting characters can cause problems for the compiler when SAS fails to automagically remove them. As Tom showed, in those cases explicitly %unquoting() the value is usually a solution.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;But not using %str() in the first place also eliminates the problem. Since &amp;amp;a1 is going to be part of a data set name, there's no need for %str() at all, there cannot be special characters in the data set name that %str() has to mask.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jul 2022 15:56:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-are-two-datasets-created-here-instead-of-1/m-p/824390#M325582</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-07-20T15:56:47Z</dc:date>
    </item>
  </channel>
</rss>

