<?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: When is proper time to add dot . after macro variables? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/When-is-proper-time-to-add-dot-after-macro-variables/m-p/404465#M279051</link>
    <description>&lt;P&gt;The dot is needed when the macro processor would not be able to detect the end of the macro variables name.&amp;nbsp; So if the macro variable name is followed immediately by a letter or digit that could possible be part of the macro variable name then you need to include the dot. So in this example we need the dot so that SAS knows you mean the macro variable PREFIX and not the macro variable PREFIXYZ.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let prefix=X;
%put &amp;amp;prefix.YZ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But also when the dot is there it becomes part of the macro variable reference.&amp;nbsp; That is what is causing confusion in your example. So if the text that you want to follow immediately after the macro variable's value starts with a dot then there also needs to be a dot to end the macro variable reference. Otherwise the macro processor will consider the dot part of the macro variable reference.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It does not hurt to always add the dot.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 16 Oct 2017 14:32:06 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2017-10-16T14:32:06Z</dc:date>
    <item>
      <title>When is proper time to add dot . after macro variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/When-is-proper-time-to-add-dot-after-macro-variables/m-p/404458#M279047</link>
      <description>&lt;P&gt;Hello:&lt;/P&gt;
&lt;P&gt;I was told a dot should be placed after macro variable.&amp;nbsp; I found sometime is needed, sometime isn't.&amp;nbsp;&amp;nbsp; Please advice when should add .?&amp;nbsp; Is there any rule for that?&amp;nbsp; Thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; State=CA;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Year=2009;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;For example,&amp;nbsp;no matter I&amp;nbsp;added&amp;nbsp;dot&amp;nbsp;. after '&amp;amp;state' or '&amp;amp;year'.&amp;nbsp; It looks the codes is working.&amp;nbsp; However, if the dot is missing after 'poverty&amp;amp;year..csv', the program stopped running due to the reference wasn't recognized.&amp;nbsp;&amp;nbsp; So I am confused that when I should add the dot properly.&amp;nbsp; Thanks.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;PROC&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;IMPORT&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;OUT&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=Poverty&amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;state.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;amp;year &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;DATAFILE&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;= &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"\\abc.org\project\Share\\ACS\&amp;amp;state.\&amp;amp;year.\Poverty&amp;amp;year..csv"&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;DBMS&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=CSV REPLACE;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;GETNAMES&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=YES;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;DATAROW&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;3&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;RUN&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;PROC&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;IMPORT&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;OUT&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=Poverty&amp;amp;state&amp;amp;year &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;DATAFILE&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;= &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"\\abc.org\project\Share\ACS\&amp;amp;state\&amp;amp;year\Poverty&amp;amp;year..csv"&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;DBMS&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=CSV REPLACE;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;GETNAMES&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=YES;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;DATAROW&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;3&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;RUN&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;Below is Error message shown if the dot is missing in '&lt;FONT color="#800080" face="Courier New" size="2"&gt;Poverty&amp;amp;year'&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ERROR: Import unsuccessful. See SAS Log for details.&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;PROC&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;IMPORT&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;OUT&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=Poverty&amp;amp;state&amp;amp;year &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;DATAFILE&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;= &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"\\abc.org\project\Share\ACS\&amp;amp;state\&amp;amp;year\Poverty&amp;amp;year.csv"&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;DBMS&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=CSV REPLACE;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;GETNAMES&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=YES;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;DATAROW&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;3&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;RUN&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Oct 2017 14:04:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/When-is-proper-time-to-add-dot-after-macro-variables/m-p/404458#M279047</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-10-16T14:04:23Z</dc:date>
    </item>
    <item>
      <title>Re: When is proper time to add dot . after macro variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/When-is-proper-time-to-add-dot-after-macro-variables/m-p/404460#M279048</link>
      <description>&lt;P&gt;It's never wrong to have the dot, but it can cause problems to not use it. Therefore you should make it your practice to always use it.&lt;/P&gt;
&lt;P&gt;In your example with&lt;/P&gt;
&lt;PRE&gt;%let year=2009;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Poverty&amp;amp;year..csv&lt;/PRE&gt;
&lt;P&gt;will resolve to&lt;/P&gt;
&lt;PRE&gt;Poverty2009.csv&lt;/PRE&gt;
&lt;P&gt;while&lt;/P&gt;
&lt;PRE&gt;Poverty&amp;amp;year.csv&lt;/PRE&gt;
&lt;P&gt;will resolve to&lt;/P&gt;
&lt;PRE&gt;Poverty2009csv&lt;/PRE&gt;
&lt;P&gt;as the dot is consumed by the macro variable resolution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As long as you keep asking yourself "should I use the dot", use it always. Only a programmer who is firm with macro programming can get away with using the dot selectively, but it is not considered good practice.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Oct 2017 14:21:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/When-is-proper-time-to-add-dot-after-macro-variables/m-p/404460#M279048</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-16T14:21:56Z</dc:date>
    </item>
    <item>
      <title>Re: When is proper time to add dot . after macro variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/When-is-proper-time-to-add-dot-after-macro-variables/m-p/404461#M279049</link>
      <description>&lt;P&gt;Right nice easy one this one.&amp;nbsp; A macro variable is ended by space, semicolon, dot or other special character per the tokenizer.&amp;nbsp; Therefore:&lt;/P&gt;
&lt;PRE&gt;"Something &amp;amp;mymacro will work"&lt;/PRE&gt;
&lt;P&gt;Because the space terminates the macro variable.&amp;nbsp; However you have to remember what the full expanded code would look like, so in a filename:&lt;/P&gt;
&lt;PRE&gt;"&amp;amp;mymacro.xls"&lt;/PRE&gt;
&lt;P&gt;Will resolve is mymacro is abc:&lt;/P&gt;
&lt;PRE&gt;"abcxls"&lt;/PRE&gt;
&lt;P&gt;As the dot terminates the macro variable and therefore is not in the final code, which would be wrong, hence you need two dots there:&lt;/P&gt;
&lt;PRE&gt;"&amp;amp;mymacro..xls"&lt;/PRE&gt;
&lt;P&gt;One to terminate, the other as part of the string.&amp;nbsp; So - and this is my opinion - in technical terms the dot might not always be needed, however as best programming practice I would &lt;U&gt;&lt;STRONG&gt;always&lt;/STRONG&gt;&lt;/U&gt; want to see the dot present, both for completeness, understanding of the code, and it also makes the macro variable highlight in a different color (well most cases) so its easy to see.&amp;nbsp; Like anything else codewise, you could put all your code on one line or type all in upcase, but is it good practice?&lt;/P&gt;</description>
      <pubDate>Mon, 16 Oct 2017 14:22:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/When-is-proper-time-to-add-dot-after-macro-variables/m-p/404461#M279049</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-10-16T14:22:59Z</dc:date>
    </item>
    <item>
      <title>Re: When is proper time to add dot . after macro variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/When-is-proper-time-to-add-dot-after-macro-variables/m-p/404462#M279050</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9&lt;/a&gt; wrote:&lt;BR /&gt; Like anything else codewise, you could put all your code on one line or type all in upcase, but is it good practice?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Like that.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Oct 2017 14:24:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/When-is-proper-time-to-add-dot-after-macro-variables/m-p/404462#M279050</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-16T14:24:30Z</dc:date>
    </item>
    <item>
      <title>Re: When is proper time to add dot . after macro variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/When-is-proper-time-to-add-dot-after-macro-variables/m-p/404465#M279051</link>
      <description>&lt;P&gt;The dot is needed when the macro processor would not be able to detect the end of the macro variables name.&amp;nbsp; So if the macro variable name is followed immediately by a letter or digit that could possible be part of the macro variable name then you need to include the dot. So in this example we need the dot so that SAS knows you mean the macro variable PREFIX and not the macro variable PREFIXYZ.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let prefix=X;
%put &amp;amp;prefix.YZ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But also when the dot is there it becomes part of the macro variable reference.&amp;nbsp; That is what is causing confusion in your example. So if the text that you want to follow immediately after the macro variable's value starts with a dot then there also needs to be a dot to end the macro variable reference. Otherwise the macro processor will consider the dot part of the macro variable reference.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It does not hurt to always add the dot.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Oct 2017 14:32:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/When-is-proper-time-to-add-dot-after-macro-variables/m-p/404465#M279051</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-10-16T14:32:06Z</dc:date>
    </item>
    <item>
      <title>Re: When is proper time to add dot . after macro variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/When-is-proper-time-to-add-dot-after-macro-variables/m-p/404543#M279052</link>
      <description>&lt;P&gt;Thank you so much for all of the thorough explanation.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Oct 2017 18:33:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/When-is-proper-time-to-add-dot-after-macro-variables/m-p/404543#M279052</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-10-16T18:33:48Z</dc:date>
    </item>
  </channel>
</rss>

