<?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: Create Multiple Files Conditionally in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-Multiple-Files-Conditionally/m-p/195094#M36698</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Little correction on Jag's code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It should be &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;%do i = 1 &lt;STRONG&gt;%to&lt;/STRONG&gt; 3; *percentage symbol was missing in initial code.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 05 Mar 2015 13:20:17 GMT</pubDate>
    <dc:creator>RamKumar</dc:creator>
    <dc:date>2015-03-05T13:20:17Z</dc:date>
    <item>
      <title>Create Multiple Files Conditionally</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Multiple-Files-Conditionally/m-p/195091#M36695</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have the below dataset:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Name&lt;/P&gt;&lt;P&gt;Jack Chirikjian&lt;/P&gt;&lt;P&gt;Dean Rosenthal&lt;/P&gt;&lt;P&gt;Dean Rosenthal&lt;/P&gt;&lt;P&gt;Dean Rosenthal&lt;/P&gt;&lt;P&gt;John Adams&lt;/P&gt;&lt;P&gt;John Adams&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need a code which will conditionally create text (tab delimited files), each containing the names.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;E.g: File1.txt&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Jack Chirikjian&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;File2.txt&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;Dean Rosenthal&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;Dean Rosenthal&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;Dean Rosenthal&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;File3.txt&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;John Adams&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;John Adams&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;Also, I need to email these files as attachments to their respective emails. Eg Jack will get an email with file1.txt, Dean will get with File2.txt and so on. (assume I have the emails addresses)&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;Greatly appreciate the inputs.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Mar 2015 11:24:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Multiple-Files-Conditionally/m-p/195091#M36695</guid>
      <dc:creator>sasmaverick</dc:creator>
      <dc:date>2015-03-05T11:24:05Z</dc:date>
    </item>
    <item>
      <title>Re: Create Multiple Files Conditionally</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Multiple-Files-Conditionally/m-p/195092#M36696</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;file "filex.txt" filevar=filnam; * filex.txt is just a placeholder;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;by name;&lt;/P&gt;&lt;P&gt;retain counter 0;&lt;/P&gt;&lt;P&gt;if first.name&lt;/P&gt;&lt;P&gt;then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp; counter + 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; filnam = 'file' !! trim(put(counter,3.)) !! '.txt';&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;put name;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Mar 2015 11:48:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Multiple-Files-Conditionally/m-p/195092#M36696</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2015-03-05T11:48:46Z</dc:date>
    </item>
    <item>
      <title>Re: Create Multiple Files Conditionally</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Multiple-Files-Conditionally/m-p/195093#M36697</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;consider that you have the email address as well in the dataset. Then this code should be helpful&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;input Name &amp;amp;$30. email :$20.;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Jack Chirikjian&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;A class="jive-link-email-small" href="mailto:jag@gmail.com"&gt;jag@gmail.com&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Dean Rosenthal&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;A class="jive-link-email-small" href="mailto:de@gmail.com"&gt;de@gmail.com&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Dean Rosenthal&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;A class="jive-link-email-small" href="mailto:de@gmail.com"&gt;de@gmail.com&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Dean Rosenthal&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;A class="jive-link-email-small" href="mailto:de@gmail.com"&gt;de@gmail.com&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;John Adams&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;A class="jive-link-email-small" href="mailto:jo@gmail.com"&gt;jo@gmail.com&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;John Adams&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;A class="jive-link-email-small" href="mailto:jo@gmail.com"&gt;jo@gmail.com&lt;/A&gt;&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;select distinct name,&amp;nbsp; email into : name1-:name&amp;amp;sysmaxlong, :email1-:email&amp;amp;sysmaxlong from have;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%put &amp;amp;name1 &amp;amp;name2 &amp;amp;email2;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro email;&lt;/P&gt;&lt;P&gt;%do i = 1 to 3;&lt;/P&gt;&lt;P&gt;DATA _NULL_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; where name="&amp;amp;&amp;amp;name&amp;amp;i";&lt;/P&gt;&lt;P&gt;FILE&amp;nbsp; '~\&amp;amp;&amp;amp;file&amp;amp;i.txt';&lt;/P&gt;&lt;P&gt;PUT name;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;FILENAME MailBox EMAIL "&amp;amp;&amp;amp;email&amp;amp;i"&lt;/P&gt;&lt;P&gt;SUBJECT='Mail message with txt attachment' &lt;/P&gt;&lt;P&gt;attach="~\&amp;amp;&amp;amp;file&amp;amp;i.txt";&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;file mailbox;&lt;/P&gt;&lt;P&gt;put 'hi';&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%email;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Jag&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Mar 2015 13:03:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Multiple-Files-Conditionally/m-p/195093#M36697</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2015-03-05T13:03:41Z</dc:date>
    </item>
    <item>
      <title>Re: Create Multiple Files Conditionally</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Multiple-Files-Conditionally/m-p/195094#M36698</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Little correction on Jag's code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It should be &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;%do i = 1 &lt;STRONG&gt;%to&lt;/STRONG&gt; 3; *percentage symbol was missing in initial code.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Mar 2015 13:20:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Multiple-Files-Conditionally/m-p/195094#M36698</guid>
      <dc:creator>RamKumar</dc:creator>
      <dc:date>2015-03-05T13:20:17Z</dc:date>
    </item>
    <item>
      <title>Re: Create Multiple Files Conditionally</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Multiple-Files-Conditionally/m-p/195095#M36699</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the correction, Ram&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Mar 2015 13:29:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Multiple-Files-Conditionally/m-p/195095#M36699</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2015-03-05T13:29:06Z</dc:date>
    </item>
    <item>
      <title>Re: Create Multiple Files Conditionally</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Multiple-Files-Conditionally/m-p/195096#M36700</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks a lot Jagadish! Works for me!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Mar 2015 14:05:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Multiple-Files-Conditionally/m-p/195096#M36700</guid>
      <dc:creator>sasmaverick</dc:creator>
      <dc:date>2015-03-05T14:05:47Z</dc:date>
    </item>
  </channel>
</rss>

