<?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: Resolving Macro Variable  in INFILE statement having single (') and  double (&amp;quot;) Quotes in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Resolving-Macro-Variable-in-INFILE-statement-having-single-and/m-p/842805#M333262</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/350312"&gt;@SASuserlot&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you , your solution made it&lt;span class="lia-unicode-emoji" title=":smiling_face_with_heart_eyes:"&gt;😍&lt;/span&gt;. Is there any reference paper or link, that I can refer, I always have the trouble with these double and single quotes specially when both of them there.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;They seem to have removed (or hidden in some hard to find place) the &lt;STRONG&gt;SAS Language&lt;/STRONG&gt; documentation where this type of topic was discussed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the description in the on-line SAS 9.3 documentation.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://support.sas.com/documentation/cdl/en/lrcon/65287/HTML/default/viewer.htm#p0cq7f0icfjr8vn19vyunwmmsl7m.htm" target="_blank" rel="noopener"&gt;https://support.sas.com/documentation/cdl/en/lrcon/65287/HTML/default/viewer.htm#p0cq7f0icfjr8vn19vyunwmmsl7m.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Using Quotation Marks with Character Constants&lt;/STRONG&gt;&lt;BR /&gt;In the following SAS statement, Tom is a character constant:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if name='Tom' then do;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;If a character constant includes a single quotation mark, surround it with double quotation marks. For example, to specify the character value Tom's as a constant, enter&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;name="Tom's"&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;Another way to write the same string is to enclose the string in single quotation marks and to express the apostrophe as two consecutive quotation marks. SAS treats the two consecutive quotation marks as one quotation mark:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;name='Tom''s'&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;The same principle holds true for double quotation marks:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;name="Tom""s"&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;CAUTION:&lt;BR /&gt;Matching quotation marks correctly is important.&lt;BR /&gt;Missing or extraneous quotation marks cause SAS to misread both the erroneous statement and the statements that follow it. For example, in name='O'Brien';, O is the character value of NAME, Brien is extraneous, and '; begins another quoted string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 07 Nov 2022 01:58:45 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2022-11-07T01:58:45Z</dc:date>
    <item>
      <title>Resolving Macro Variable  in INFILE statement having single (') and  double (") Quotes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Resolving-Macro-Variable-in-INFILE-statement-having-single-and/m-p/842779#M333248</link>
      <description>&lt;P&gt;&amp;nbsp;I am trying to access the files in a path&amp;nbsp; and trying to convert into Macro. My macro variables are not resolving since the INFILE statement have both single and double quotes. I tried using&amp;nbsp; Multiple double quotes, %bquote, or "%'". But not successful. If I use the the&amp;nbsp; "Double quotes" before the 'Dir' then it throwing me error. How I can I convert this into Macro and resolve the Macro variables. The path is working without Converting to Macro. Thank you for your inputs.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options symbolgen mprint mlogic;
 %let folder = document;
 %let loc = Desktop;

 
data filenames_;
  infile 'dir "D:\&amp;amp;loc.\&amp;amp;folder.\*" /B/S/A-D/ON' pipe truncover;
  input path_file $1000.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 06 Nov 2022 19:29:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Resolving-Macro-Variable-in-INFILE-statement-having-single-and/m-p/842779#M333248</guid>
      <dc:creator>SASuserlot</dc:creator>
      <dc:date>2022-11-06T19:29:10Z</dc:date>
    </item>
    <item>
      <title>Re: Resolving Macro Variable  in INFILE statement having single (') and  double (") Quotes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Resolving-Macro-Variable-in-INFILE-statement-having-single-and/m-p/842781#M333249</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/350312"&gt;@SASuserlot&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First replace the single quotes by double quotes. For your example values of &lt;FONT face="courier new,courier"&gt;folder&lt;/FONT&gt; and &lt;FONT face="courier new,courier"&gt;doc&lt;/FONT&gt; you can just delete the inner (double) quotes. If you need them (potentially) for other values of the macro variables (e.g., folder names containing blanks), duplicate the inner double quotes:&lt;/P&gt;
&lt;PRE&gt;&lt;FONT size="4"&gt;infile &lt;FONT color="#3366FF"&gt;&lt;STRONG&gt;"&lt;/STRONG&gt;&lt;/FONT&gt;dir &lt;FONT color="#3366FF"&gt;&lt;STRONG&gt;""&lt;/STRONG&gt;&lt;/FONT&gt;D:\&amp;amp;loc.\&amp;amp;folder.\*&lt;FONT color="#3366FF"&gt;&lt;STRONG&gt;""&lt;/STRONG&gt;&lt;/FONT&gt; /B/S/A-D/ON&lt;FONT color="#3366FF"&gt;&lt;STRONG&gt;"&lt;/STRONG&gt;&lt;/FONT&gt; pipe truncover;&lt;/FONT&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 06 Nov 2022 20:11:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Resolving-Macro-Variable-in-INFILE-statement-having-single-and/m-p/842781#M333249</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2022-11-06T20:11:41Z</dc:date>
    </item>
    <item>
      <title>Re: Resolving Macro Variable  in INFILE statement having single (') and  double (") Quotes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Resolving-Macro-Variable-in-INFILE-statement-having-single-and/m-p/842803#M333260</link>
      <description>&lt;P&gt;Thank you , your solution made it&lt;span class="lia-unicode-emoji" title=":smiling_face_with_heart_eyes:"&gt;😍&lt;/span&gt;. Is there any reference paper or link, that I can refer, I always have the trouble with these double and single quotes specially when both of them there.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Nov 2022 01:35:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Resolving-Macro-Variable-in-INFILE-statement-having-single-and/m-p/842803#M333260</guid>
      <dc:creator>SASuserlot</dc:creator>
      <dc:date>2022-11-07T01:35:15Z</dc:date>
    </item>
    <item>
      <title>Re: Resolving Macro Variable  in INFILE statement having single (') and  double (") Quotes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Resolving-Macro-Variable-in-INFILE-statement-having-single-and/m-p/842805#M333262</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/350312"&gt;@SASuserlot&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you , your solution made it&lt;span class="lia-unicode-emoji" title=":smiling_face_with_heart_eyes:"&gt;😍&lt;/span&gt;. Is there any reference paper or link, that I can refer, I always have the trouble with these double and single quotes specially when both of them there.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;They seem to have removed (or hidden in some hard to find place) the &lt;STRONG&gt;SAS Language&lt;/STRONG&gt; documentation where this type of topic was discussed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the description in the on-line SAS 9.3 documentation.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://support.sas.com/documentation/cdl/en/lrcon/65287/HTML/default/viewer.htm#p0cq7f0icfjr8vn19vyunwmmsl7m.htm" target="_blank" rel="noopener"&gt;https://support.sas.com/documentation/cdl/en/lrcon/65287/HTML/default/viewer.htm#p0cq7f0icfjr8vn19vyunwmmsl7m.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Using Quotation Marks with Character Constants&lt;/STRONG&gt;&lt;BR /&gt;In the following SAS statement, Tom is a character constant:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if name='Tom' then do;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;If a character constant includes a single quotation mark, surround it with double quotation marks. For example, to specify the character value Tom's as a constant, enter&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;name="Tom's"&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;Another way to write the same string is to enclose the string in single quotation marks and to express the apostrophe as two consecutive quotation marks. SAS treats the two consecutive quotation marks as one quotation mark:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;name='Tom''s'&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;The same principle holds true for double quotation marks:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;name="Tom""s"&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;CAUTION:&lt;BR /&gt;Matching quotation marks correctly is important.&lt;BR /&gt;Missing or extraneous quotation marks cause SAS to misread both the erroneous statement and the statements that follow it. For example, in name='O'Brien';, O is the character value of NAME, Brien is extraneous, and '; begins another quoted string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Nov 2022 01:58:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Resolving-Macro-Variable-in-INFILE-statement-having-single-and/m-p/842805#M333262</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-11-07T01:58:45Z</dc:date>
    </item>
    <item>
      <title>Re: Resolving Macro Variable  in INFILE statement having single (') and  double (") Quotes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Resolving-Macro-Variable-in-INFILE-statement-having-single-and/m-p/842835#M333273</link>
      <description>&lt;P&gt;Thanks to&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;for providing the documentation link during the European night. The corresponding documentation for SAS 9.4/Viya 3.5 is&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lrcon/p0cq7f0icfjr8vn19vyunwmmsl7m.htm" target="_blank" rel="noopener"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lrcon/p0cq7f0icfjr8vn19vyunwmmsl7m.htm&lt;/A&gt;. But, strangely enough, switching to the latest Viya version 2022.10 leads to a page saying "&lt;SPAN&gt;The page you were viewing is unavailable for the version you selected." Applying the recent "&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Pro-tip-How-to-view-the-latest-SAS-documentation/ta-p/841970" target="_blank" rel="noopener"&gt;Pro-tip: How to view the latest SAS documentation&lt;/A&gt;" to the "9.4_3.5" part of the URL yields "Page Not Found".&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Luckily, older documentation (at least back to &lt;A href="http://v8doc.sas.com/sashtml/main.htm" target="_blank" rel="noopener"&gt;SAS V8&lt;/A&gt;) and &lt;A href="https://www.lexjansen.com/" target="_blank" rel="noopener"&gt;conference papers&lt;/A&gt; are still available online, a number of long-time SAS users in this forum remember what they learned using SAS V6 and earlier (which is how I recalled the double double-quote trick) and a few of them even &lt;A href="https://communities.sas.com/t5/SAS-Programming/Retain-statement-makes-me-confusing/m-p/489638/highlight/true#M127896" target="_blank" rel="noopener"&gt;own a copy of ancient printed documentation&lt;/A&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;In your example the key was basically to combine the principle "avoid single quotes around macro variable references as they prevent their resolution" with the special meaning of duplicate quotes (of the same type) in certain places.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Nov 2022 09:57:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Resolving-Macro-Variable-in-INFILE-statement-having-single-and/m-p/842835#M333273</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2022-11-07T09:57:03Z</dc:date>
    </item>
  </channel>
</rss>

