<?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: help with a macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/help-with-a-macro/m-p/107030#M22279</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I couldn't duplicate your result with SAS 9.2.3. However my editor showed an unidentified non-displayed character in the line before the macro definition. I've had unexpected results when that happens so if that character is in your code it may be worth deleteing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You may also be having issues with:&lt;/P&gt;&lt;P&gt;1) the first SQL should end in quit instead of run (minor)&lt;/P&gt;&lt;P&gt;2) the field fst_name is undefined, at least in the example data and generates an error when the macro executes with a=0. When I add the character variable fst_name to the data it behaves as I think you want.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are other ways, but generally to paste text into this forum it works best to come from a pure text editor. The old SAS Progam editor (not the enhanced) will work. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 08 Oct 2013 22:50:32 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2013-10-08T22:50:32Z</dc:date>
    <item>
      <title>help with a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/help-with-a-macro/m-p/107029#M22278</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Someone gave me some code that I can't get to work. The object of the code is that if there are no results in my final query, I want to put a message in the output file to let the recipient of the report know that there were no results.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I first created some data and ran the code to see if it would run through but I'm getting "error 180-322 Statement is invalid or it is out of proper order" at the line %mend NoRecsFound;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas what the problem is?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On another subject is there a way to paste code into the message? I see insert video, link and image but not text.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dan D.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Oct 2013 22:11:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/help-with-a-macro/m-p/107029#M22278</guid>
      <dc:creator>DanD</dc:creator>
      <dc:date>2013-10-08T22:11:19Z</dc:date>
    </item>
    <item>
      <title>Re: help with a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/help-with-a-macro/m-p/107030#M22279</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I couldn't duplicate your result with SAS 9.2.3. However my editor showed an unidentified non-displayed character in the line before the macro definition. I've had unexpected results when that happens so if that character is in your code it may be worth deleteing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You may also be having issues with:&lt;/P&gt;&lt;P&gt;1) the first SQL should end in quit instead of run (minor)&lt;/P&gt;&lt;P&gt;2) the field fst_name is undefined, at least in the example data and generates an error when the macro executes with a=0. When I add the character variable fst_name to the data it behaves as I think you want.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are other ways, but generally to paste text into this forum it works best to come from a pure text editor. The old SAS Progam editor (not the enhanced) will work. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Oct 2013 22:50:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/help-with-a-macro/m-p/107030#M22279</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2013-10-08T22:50:32Z</dc:date>
    </item>
    <item>
      <title>Re: help with a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/help-with-a-macro/m-p/107031#M22280</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think you're probably right about the non-displayed character. I had trouble with the first proc sql until I finally rewrote it and it worked. I'll retype it all tomorrow and test it. Thanks for the help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Oct 2013 02:09:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/help-with-a-macro/m-p/107031#M22280</guid>
      <dc:creator>dan999</dc:creator>
      <dc:date>2013-10-09T02:09:24Z</dc:date>
    </item>
    <item>
      <title>Re: help with a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/help-with-a-macro/m-p/107032#M22281</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The strange character in the program you attached is ASCII code A0 hex ('A0'X in SAS literals) or 160 decimal.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Some editors stick those in because they look like spaces in most fonts and make it easier to pad lines without text formatted collapsing the multiple spaces into one.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also in the INTO clause in your PROC SQL you can add SEPARATED BY clause and SAS will trim the leading spaces from the count.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can paste into the editor just like you paste into any other program. Personally I use Ctrl-V to paste.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data final;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;infile datalines;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;input country $ barrels;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;datalines;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;us 96400&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;uk 96401&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;ru 96402&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;proc sql noprint;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; select count(*)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; into :cnt separated by ' '&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; from&amp;nbsp; final&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;quit ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%macro NoRecsFound;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; %if &amp;amp;cnt = 0 %then %do;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; proc sql;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; insert into work.final&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set fst_name = "No Results for this week";&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; quit;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; %end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%mend NoRecsFound;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%NoRecsFound;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Oct 2013 02:12:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/help-with-a-macro/m-p/107032#M22281</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-10-09T02:12:00Z</dc:date>
    </item>
    <item>
      <title>Re: help with a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/help-with-a-macro/m-p/107033#M22282</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I discovered that if I try to copy and paste from SAS EG 5.1 that I'm not able to paste into here. But if I paste into Notepad and then copy and paste from Notepad into here, it works. Weird.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for all of the help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Oct 2013 12:28:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/help-with-a-macro/m-p/107033#M22282</guid>
      <dc:creator>DanD</dc:creator>
      <dc:date>2013-10-09T12:28:33Z</dc:date>
    </item>
    <item>
      <title>Re: help with a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/help-with-a-macro/m-p/107034#M22283</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I retyped the macro part and it worked. Thanks again. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Oct 2013 12:38:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/help-with-a-macro/m-p/107034#M22283</guid>
      <dc:creator>DanD</dc:creator>
      <dc:date>2013-10-09T12:38:16Z</dc:date>
    </item>
  </channel>
</rss>

