<?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 DO Loops in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/DO-Loops/m-p/192425#M266185</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a table that has a unique identifier for each grouping of data that I would like to export to an excel file. The unique column in the table is called 'NAME'. The different groupings can be found below. This list will be changing and growing over the next few days to 40 - 50 so that is why I don't want to create multiple exports while using 40 - 50 where clause statements.&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="width: 542px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl67" height="20" width="113"&gt;VERTICAL&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="72"&gt;ProdType&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="51"&gt;COUNT&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="84"&gt;PERCENT&lt;/TD&gt;&lt;TD width="34"&gt;&lt;STRONG style="color: #ff0000;"&gt;Row&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="188"&gt;&lt;STRONG style="color: #ff0000;"&gt;Name&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20" style="border-top: none;"&gt;CORP_BANKING&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;CHK&lt;/TD&gt;&lt;TD align="right" class="xl66" style="border-top: none; border-left: none;"&gt;36&lt;/TD&gt;&lt;TD align="right" class="xl66" style="border-top: none; border-left: none;"&gt;26.08695652&lt;/TD&gt;&lt;TD align="right" class="xl66" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;CORP_BANKING_CHK&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20" style="border-top: none;"&gt;CORP_BANKING&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;MMA_SAV&lt;/TD&gt;&lt;TD align="right" class="xl66" style="border-top: none; border-left: none;"&gt;30&lt;/TD&gt;&lt;TD align="right" class="xl66" style="border-top: none; border-left: none;"&gt;21.73913043&lt;/TD&gt;&lt;TD align="right" class="xl66" style="border-top: none; border-left: none;"&gt;2&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;CORP_BANKING_MMA_SAV&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20" style="border-top: none;"&gt;MIDDLE_MARKET&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;CHK&lt;/TD&gt;&lt;TD align="right" class="xl66" style="border-top: none; border-left: none;"&gt;36&lt;/TD&gt;&lt;TD align="right" class="xl66" style="border-top: none; border-left: none;"&gt;26.08695652&lt;/TD&gt;&lt;TD align="right" class="xl66" style="border-top: none; border-left: none;"&gt;3&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;MIDDLE_MARKET_CHK&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20" style="border-top: none;"&gt;MIDDLE_MARKET&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;MMA_SAV&lt;/TD&gt;&lt;TD align="right" class="xl66" style="border-top: none; border-left: none;"&gt;36&lt;/TD&gt;&lt;TD align="right" class="xl66" style="border-top: none; border-left: none;"&gt;26.08695652&lt;/TD&gt;&lt;TD align="right" class="xl66" style="border-top: none; border-left: none;"&gt;4&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;MIDDLE_MARKET_MMA_SAV&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="line-height: 1.5em; font-size: 10pt;"&gt;For my master data set I would like to create a do loop so that &lt;/SPAN&gt;every time a new Name/Row is identified a proc export to an Excel file would be executed for those groupings of accounts. I would also like to include the "Name" to the Excel export.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I create something dynamic so that I can export all unique names separately from my master table with the "Name" of the grouping in the file name?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any examples or suggestions would be greatly appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 25 Apr 2014 17:27:34 GMT</pubDate>
    <dc:creator>SasGuy614</dc:creator>
    <dc:date>2014-04-25T17:27:34Z</dc:date>
    <item>
      <title>DO Loops</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-Loops/m-p/192425#M266185</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a table that has a unique identifier for each grouping of data that I would like to export to an excel file. The unique column in the table is called 'NAME'. The different groupings can be found below. This list will be changing and growing over the next few days to 40 - 50 so that is why I don't want to create multiple exports while using 40 - 50 where clause statements.&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="width: 542px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl67" height="20" width="113"&gt;VERTICAL&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="72"&gt;ProdType&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="51"&gt;COUNT&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="84"&gt;PERCENT&lt;/TD&gt;&lt;TD width="34"&gt;&lt;STRONG style="color: #ff0000;"&gt;Row&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="188"&gt;&lt;STRONG style="color: #ff0000;"&gt;Name&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20" style="border-top: none;"&gt;CORP_BANKING&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;CHK&lt;/TD&gt;&lt;TD align="right" class="xl66" style="border-top: none; border-left: none;"&gt;36&lt;/TD&gt;&lt;TD align="right" class="xl66" style="border-top: none; border-left: none;"&gt;26.08695652&lt;/TD&gt;&lt;TD align="right" class="xl66" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;CORP_BANKING_CHK&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20" style="border-top: none;"&gt;CORP_BANKING&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;MMA_SAV&lt;/TD&gt;&lt;TD align="right" class="xl66" style="border-top: none; border-left: none;"&gt;30&lt;/TD&gt;&lt;TD align="right" class="xl66" style="border-top: none; border-left: none;"&gt;21.73913043&lt;/TD&gt;&lt;TD align="right" class="xl66" style="border-top: none; border-left: none;"&gt;2&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;CORP_BANKING_MMA_SAV&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20" style="border-top: none;"&gt;MIDDLE_MARKET&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;CHK&lt;/TD&gt;&lt;TD align="right" class="xl66" style="border-top: none; border-left: none;"&gt;36&lt;/TD&gt;&lt;TD align="right" class="xl66" style="border-top: none; border-left: none;"&gt;26.08695652&lt;/TD&gt;&lt;TD align="right" class="xl66" style="border-top: none; border-left: none;"&gt;3&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;MIDDLE_MARKET_CHK&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20" style="border-top: none;"&gt;MIDDLE_MARKET&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;MMA_SAV&lt;/TD&gt;&lt;TD align="right" class="xl66" style="border-top: none; border-left: none;"&gt;36&lt;/TD&gt;&lt;TD align="right" class="xl66" style="border-top: none; border-left: none;"&gt;26.08695652&lt;/TD&gt;&lt;TD align="right" class="xl66" style="border-top: none; border-left: none;"&gt;4&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;MIDDLE_MARKET_MMA_SAV&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="line-height: 1.5em; font-size: 10pt;"&gt;For my master data set I would like to create a do loop so that &lt;/SPAN&gt;every time a new Name/Row is identified a proc export to an Excel file would be executed for those groupings of accounts. I would also like to include the "Name" to the Excel export.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I create something dynamic so that I can export all unique names separately from my master table with the "Name" of the grouping in the file name?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any examples or suggestions would be greatly appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Apr 2014 17:27:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-Loops/m-p/192425#M266185</guid>
      <dc:creator>SasGuy614</dc:creator>
      <dc:date>2014-04-25T17:27:34Z</dc:date>
    </item>
    <item>
      <title>Re: DO Loops</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-Loops/m-p/192426#M266186</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="http://support.sas.com/kb/38/430.html" title="http://support.sas.com/kb/38/430.html"&gt;38430 - Exporting BY groups from a SAS data set to multiple Microsoft Excel or text files&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Apr 2014 19:19:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-Loops/m-p/192426#M266186</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-04-25T19:19:24Z</dc:date>
    </item>
    <item>
      <title>Re: DO Loops</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-Loops/m-p/192427#M266187</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A __default_attr="255172" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt;'s suggested method will be needed if your Name variable contains any characters that aren't allowed in a SAS filename.&amp;nbsp; And, like the following code, assumes that you license SAS/Access for PC File Formats, so that you can use the Excel engine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following code assumes, additionally, that your name variable contains strings that can be used directly as file names:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile cards delimiter='09'x;&lt;/P&gt;&lt;P&gt;&amp;nbsp; informat vertical $12.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; informat prodtype $8.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; informat name $30.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input VERTICAL ProdType COUNT PERCENT Row Name;&lt;/P&gt;&lt;P&gt;&amp;nbsp; cards;&lt;/P&gt;&lt;P&gt;MIDDLE_MARKET CHK 36 26.08695652 3 MIDDLE_MARKET_CHK&lt;/P&gt;&lt;P&gt;CORP_BANKING CHK 36 26.08695652 1 CORP_BANKING_CHK&lt;/P&gt;&lt;P&gt;MIDDLE_MARKET MMA_SAV 36 26.08695652 4 MIDDLE_MARKET_MMA_SAV&lt;/P&gt;&lt;P&gt;CORP_BANKING MMA_SAV 30 21.73913043 2 CORP_BANKING_MMA_SAV&lt;/P&gt;&lt;P&gt;CORP_BANKING CHK 36 26.08695652 5 CORP_BANKING_CHK&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data temp (index=(Name));&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data temp (drop=_BankNum);&lt;/P&gt;&lt;P&gt;&amp;nbsp; set temp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by Name;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if First.Name then _BankNum+1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; BankNum=catt('_',put(_BankNum,z7.));&lt;/P&gt;&lt;P&gt;&amp;nbsp; FName=catx('.',BankNum,name,'xlsx');&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;/P&gt;&lt;P&gt;&amp;nbsp; select distinct cat('libname ',strip(BankNum),' Excel "c:\art\',&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; strip(Name),'.xlsx";'),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; catx(' ','libname',strip(BankNum),'clear;')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; into :libnames separated by ' '&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; :cleanup separated by ' '&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from temp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;amp;libnames.;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;/P&gt;&lt;P&gt;&amp;nbsp; select distinct catt("'",Name,"'")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; into :varnames separated by ','&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from dictionary.columns&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where libname='WORK' and&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; memname='TEMP' and&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; upcase(Name) ~in ('BANKNUM','FNAME') &lt;/P&gt;&lt;P&gt;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_; &lt;/P&gt;&lt;P&gt; dcl hash hh ( ); &lt;/P&gt;&lt;P&gt; hh.definekey ('k' ); &lt;/P&gt;&lt;P&gt; hh.definedata (&amp;amp;varnames.); &lt;/P&gt;&lt;P&gt; hh.definedone (); &lt;/P&gt;&lt;P&gt; do k = 1 by 1 until (last.Name); &lt;/P&gt;&lt;P&gt; set temp; &lt;/P&gt;&lt;P&gt; by name; &lt;/P&gt;&lt;P&gt; hh.add (); &lt;/P&gt;&lt;P&gt; end; &lt;/P&gt;&lt;P&gt; hh.output (dataset: FName); &lt;/P&gt;&lt;P&gt;run; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;amp;cleanup.;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Apr 2014 19:52:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-Loops/m-p/192427#M266187</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2014-04-25T19:52:40Z</dc:date>
    </item>
  </channel>
</rss>

