<?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: SAS macros for exporting to multiple sheets. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-macros-for-exporting-to-multiple-sheets/m-p/87666#M289310</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Another option is tagsets, though I think it takes longer and the file is bigger. Easier to code if you're in a rush though. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/rnd/base/ods/odsmarkup/excelxp_demo.html#data" title="http://support.sas.com/rnd/base/ods/odsmarkup/excelxp_demo.html#data"&gt;Base SAS: Demo: ExcelXP Tagset and Microsoft Excel&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 21 Sep 2013 03:56:17 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2013-09-21T03:56:17Z</dc:date>
    <item>
      <title>SAS macros for exporting to multiple sheets.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macros-for-exporting-to-multiple-sheets/m-p/87663#M289307</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have built the following simple macros for exporting a dataset into sas but creating a different sheet for each city. However it doesn't work because it is searching for city1 city2 instead of the name and therefore returning 0 results and exporting to excel naming the tabs city1 city 2 etc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there something I have missed that I need to do to make this work? Or is there some kind of alternative other than having multiple export statements which i don't want to do. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(There are more than 3 cities by the way, I just shortened this one for the sake of posting)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Stephen&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;%let&lt;/TD&gt;&lt;TD&gt;city1&lt;/TD&gt;&lt;TD&gt;=&lt;/TD&gt;&lt;TD&gt;Manchester&lt;/TD&gt;&lt;TD&gt;;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;%let&lt;/TD&gt;&lt;TD&gt;city2&lt;/TD&gt;&lt;TD&gt;=&lt;/TD&gt;&lt;TD&gt;Birmingham&lt;/TD&gt;&lt;TD&gt;;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;%let&lt;/TD&gt;&lt;TD&gt;city3&lt;/TD&gt;&lt;TD&gt;=&lt;/TD&gt;&lt;TD&gt;Bristol&lt;/TD&gt;&lt;TD&gt;;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro export;&lt;/P&gt;&lt;P&gt;%do i = 1 %to 3;&lt;/P&gt;&lt;P&gt;proc export data = file1 (where = (city = "city&amp;amp;i."))replace&lt;/P&gt;&lt;P&gt;outfile = 'file location.xls'&lt;/P&gt;&lt;P&gt;DBMS = excel;&lt;/P&gt;&lt;P&gt;sheet = "city&amp;amp;i.";&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%mend export;&lt;/P&gt;&lt;P&gt;%export&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Sep 2013 08:22:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macros-for-exporting-to-multiple-sheets/m-p/87663#M289307</guid>
      <dc:creator>troopon</dc:creator>
      <dc:date>2013-09-19T08:22:42Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macros for exporting to multiple sheets.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macros-for-exporting-to-multiple-sheets/m-p/87664#M289308</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;never mind figured it out although don't completely understand it. More trial and error&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE style="border: 0px; font-style: inherit; font-family: inherit;"&gt;&lt;TBODY style="font-style: inherit; font-family: inherit;"&gt;&lt;TR style="border: 0px; font-style: inherit; font-family: inherit;"&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; border: 0px; font-style: inherit; font-family: inherit;"&gt;%let&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; border: 0px; font-style: inherit; font-family: inherit;"&gt;city1&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; border: 0px; font-style: inherit; font-family: inherit;"&gt;=&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; border: 0px; font-style: inherit; font-family: inherit;"&gt;Manchester&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; border: 0px; font-style: inherit; font-family: inherit;"&gt;;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: 0px; font-style: inherit; font-family: inherit;"&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; border: 0px; font-style: inherit; font-family: inherit;"&gt;%let&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; border: 0px; font-style: inherit; font-family: inherit;"&gt;city2&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; border: 0px; font-style: inherit; font-family: inherit;"&gt;=&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; border: 0px; font-style: inherit; font-family: inherit;"&gt;Birmingham&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; border: 0px; font-style: inherit; font-family: inherit;"&gt;;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: 0px; font-style: inherit; font-family: inherit;"&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; border: 0px; font-style: inherit; font-family: inherit;"&gt;%let&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; border: 0px; font-style: inherit; font-family: inherit;"&gt;city3&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; border: 0px; font-style: inherit; font-family: inherit;"&gt;=&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; border: 0px; font-style: inherit; font-family: inherit;"&gt;Bristol&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; border: 0px; font-style: inherit; font-family: inherit;"&gt;;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: 0px; font-style: inherit; font-family: inherit;"&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; border: 0px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;%macro export;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;%do i = 1 %to 3;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;%put number is &amp;amp;i &amp;amp;&amp;amp;centre&amp;amp;i;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc export data = file1 (where = (centre_formatted = "&amp;amp;&amp;amp;city&amp;amp;i."))replace&lt;/P&gt;&lt;P&gt;outfile = 'file location.xls'&lt;/P&gt;&lt;P&gt;DBMS = excel;&lt;/P&gt;&lt;P&gt;sheet = "&amp;amp;&amp;amp;city&amp;amp;i.";&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%mend export;&lt;/P&gt;&lt;P&gt;%export&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Sep 2013 08:54:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macros-for-exporting-to-multiple-sheets/m-p/87664#M289308</guid>
      <dc:creator>troopon</dc:creator>
      <dc:date>2013-09-19T08:54:48Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macros for exporting to multiple sheets.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macros-for-exporting-to-multiple-sheets/m-p/87665#M289309</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Looks like &amp;amp;&amp;amp;centre&amp;amp;i should be &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.727272033691406px; background-color: #ffffff;"&gt;&amp;amp;&amp;amp;city&amp;amp;i.&lt;/SPAN&gt;&amp;nbsp; (In this case the period after &amp;amp;i is OK but not needed)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When the SAS macro processor encounters multiple "&amp;amp;" it replaces each pair with a single and then evaluates the expression again, repeatedly, until all multiple instances are reduced to one.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Input:&amp;nbsp;&amp;nbsp; &lt;STRONG style="font-size: 12.727272033691406px; background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&amp;amp;&amp;amp;city&amp;amp;i.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.727272033691406px; background-color: #ffffff;"&gt;First pass:&amp;nbsp; resolves to &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.727272033691406px; background-color: #ffffff;"&gt;&lt;STRONG&gt;&amp;amp;city1&lt;/STRONG&gt; (assuming &amp;amp;i = 1)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12.727272033691406px; background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;Final pass: resolves to &lt;STRONG style="font-size: 12.727272033691406px; background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;Manchester&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12.727272033691406px; background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12.727272033691406px; background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;Richard&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 21 Sep 2013 00:01:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macros-for-exporting-to-multiple-sheets/m-p/87665#M289309</guid>
      <dc:creator>RichardinOz</dc:creator>
      <dc:date>2013-09-21T00:01:25Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macros for exporting to multiple sheets.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macros-for-exporting-to-multiple-sheets/m-p/87666#M289310</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Another option is tagsets, though I think it takes longer and the file is bigger. Easier to code if you're in a rush though. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/rnd/base/ods/odsmarkup/excelxp_demo.html#data" title="http://support.sas.com/rnd/base/ods/odsmarkup/excelxp_demo.html#data"&gt;Base SAS: Demo: ExcelXP Tagset and Microsoft Excel&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 21 Sep 2013 03:56:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macros-for-exporting-to-multiple-sheets/m-p/87666#M289310</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-09-21T03:56:17Z</dc:date>
    </item>
  </channel>
</rss>

