<?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 in this case it does not need double quotation marks ？ in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/why-in-this-case-it-does-not-need-double-quotation-marks/m-p/762704#M241508</link>
    <description>&lt;P&gt;Thank you for your help.&lt;/P&gt;</description>
    <pubDate>Thu, 19 Aug 2021 21:37:42 GMT</pubDate>
    <dc:creator>tianerhu</dc:creator>
    <dc:date>2021-08-19T21:37:42Z</dc:date>
    <item>
      <title>why in this case it does not need double quotation marks ？</title>
      <link>https://communities.sas.com/t5/SAS-Programming/why-in-this-case-it-does-not-need-double-quotation-marks/m-p/762699#M241505</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Complete the code below to reference a data set named&amp;nbsp;&lt;STRONG&gt;data_in&lt;/STRONG&gt; that is contained in the library &lt;STRONG&gt;cert&lt;/STRONG&gt;. You must use the macro variable defined in the program in place of the data set name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let dsref= cert.data_in; libname cert "C:\workshop\cert";&lt;/P&gt;
&lt;P&gt;data work.data_out; set &lt;LABEL class="accesshide" for="q356520:48_answer"&gt;Answer&lt;/LABEL&gt;&lt;INPUT id="q356520:48_answer" class="form-control d-inline incorrect" name="q356520:48_answer" readonly="readonly" size="22" type="text" value="&amp;quot;&amp;amp;dsref&amp;quot;" /&gt;&lt;I class="icon fa fa-remove text-danger fa-fw " aria-label="Incorrect"&gt;&lt;/I&gt;; run;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the correct answer : &amp;amp;dsref , why ?&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Aug 2021 21:18:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/why-in-this-case-it-does-not-need-double-quotation-marks/m-p/762699#M241505</guid>
      <dc:creator>tianerhu</dc:creator>
      <dc:date>2021-08-19T21:18:48Z</dc:date>
    </item>
    <item>
      <title>Re: why in this case it does not need double quotation marks ？</title>
      <link>https://communities.sas.com/t5/SAS-Programming/why-in-this-case-it-does-not-need-double-quotation-marks/m-p/762700#M241506</link>
      <description>&lt;P&gt;Macro variables are just a text substitution mechanism. When you execute SAS code, the value of the macro variable (a text string) is substituted into SAS code (where the macro variable was in the code), and this substitution of macro variable value into the code MUST produce valid working legal SAS code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, can you spot the error in this code, after the macro variable value is substituted into the code? Is this valid working legal SAS code?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.data_out;
    set "cert.data_in";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you had typed the above without a macro variable, will it work? Will it run? What is the problem? If it doesn't work without macro variables, then doing the same thing with macro variables also will not work.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;What about this code? Is it valid legal working SAS code? Will it run?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.data_out;
    set cert.data_in;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Aug 2021 21:27:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/why-in-this-case-it-does-not-need-double-quotation-marks/m-p/762700#M241506</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-08-19T21:27:54Z</dc:date>
    </item>
    <item>
      <title>Re: why in this case it does not need double quotation marks ？</title>
      <link>https://communities.sas.com/t5/SAS-Programming/why-in-this-case-it-does-not-need-double-quotation-marks/m-p/762703#M241507</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/268447"&gt;@tianerhu&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Complete the code below to reference a data set named&amp;nbsp;&lt;STRONG&gt;data_in&lt;/STRONG&gt; that is contained in the library &lt;STRONG&gt;cert&lt;/STRONG&gt;. You must use the macro variable defined in the program in place of the data set name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let dsref= cert.data_in; libname cert "C:\workshop\cert";&lt;/P&gt;
&lt;P&gt;data work.data_out; set &lt;LABEL class="accesshide" for="q356520:48_answer"&gt;Answer&lt;/LABEL&gt;&lt;INPUT id="q356520:48_answer" class="form-control d-inline incorrect" name="q356520:48_answer" readonly="readonly" size="22" type="text" value="&amp;quot;&amp;amp;dsref&amp;quot;" /&gt;&lt;I class="icon fa fa-remove text-danger fa-fw " aria-label="Incorrect"&gt;&lt;/I&gt;; run;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the correct answer : &amp;amp;dsref , why ?&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Consider that the basic way to write a set statement is libname.datasetname. Suppose I want to use the SAS supplied data set Sashelp.class on a set statement. The data step would look like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Data work.want;
   set sashelp.class;
&amp;lt;any other programming statements&amp;gt;
run;&lt;/PRE&gt;
&lt;P&gt;If I place quotes around the data set name like "sashelp.class" this is what happens:&lt;/P&gt;
&lt;PRE&gt;213  Data work.want;
214     set "sashelp.class";
ERROR: Extension for physical file name "sashelp.class" does not correspond to a valid member
       type.
215  /*any other programming statements*/
216  run;
&lt;/PRE&gt;
&lt;P&gt;The double quotes are needed when I want the value treated as a string value. A statement to assign a value to a variable perhaps like:&lt;/P&gt;
&lt;P&gt;Name='John';&lt;/P&gt;
&lt;P&gt;If John was stored in a macro variable the statement would be&lt;/P&gt;
&lt;P&gt;Name="&amp;amp;Macrovar";&lt;/P&gt;
&lt;P&gt;because the use of the variable as a value requires quotes.&lt;/P&gt;
&lt;P&gt;If I want to create a new variable in the data set using a macro variable to hold the name it would not be in quotes because for most uses variable names aren't in quotes.&lt;/P&gt;
&lt;PRE&gt;%let newvar=Boyname;
Data work.want;
   set sashelp.class;
   if sex='M' then &amp;amp;newvar.=Name;
run;&lt;/PRE&gt;
&lt;P&gt;The rule depends on what the value is used for. If the use requires quotes such as literal value or an external file name then the macro variable is in double quotes so it will resolve but the result is still quoted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Moral of the story is get the code working without macro variables. Then look at the code an what you replace gets quoted or not based on usage.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Aug 2021 21:31:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/why-in-this-case-it-does-not-need-double-quotation-marks/m-p/762703#M241507</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-08-19T21:31:11Z</dc:date>
    </item>
    <item>
      <title>Re: why in this case it does not need double quotation marks ？</title>
      <link>https://communities.sas.com/t5/SAS-Programming/why-in-this-case-it-does-not-need-double-quotation-marks/m-p/762704#M241508</link>
      <description>&lt;P&gt;Thank you for your help.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Aug 2021 21:37:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/why-in-this-case-it-does-not-need-double-quotation-marks/m-p/762704#M241508</guid>
      <dc:creator>tianerhu</dc:creator>
      <dc:date>2021-08-19T21:37:42Z</dc:date>
    </item>
  </channel>
</rss>

