<?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: Export dataset by ID to mutiple pipe delimited text files in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Export-dataset-by-ID-to-mutiple-pipe-delimited-text-files/m-p/225191#M40406</link>
    <description>&lt;P&gt;You'll need to explicitly write your export in a data _null_ step but then you can use the FILEVAR option to split the files automatically.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's an example based on the SASHELP.CARS dataset. &amp;nbsp;Note the DLM option used to specify the delimiter and that the header names are explicitly defined.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SORT DATA=SASHELP.CARS OUT=CARS;
BY make;
RUN;


DATA _NULL_;

SET cars; *Dataset to be exported;
BY make; *Variable that file is to be split on;

*Create path to file that is to be exported;
if first.make then out_file=cats('C:\_localdata\temp\', trim(make), ".txt");

file temp filevar=out_file dlm='|' dsd;

*If first value of make then output column names;
if first.make then 
put 'Make|Model|MPG_HIGHWAY|MPG_CITY';

*Output variables;
put make model mpg_highway mpg_city;

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 11 Sep 2015 15:42:27 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2015-09-11T15:42:27Z</dc:date>
    <item>
      <title>Export dataset by ID to mutiple pipe delimited text files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Export-dataset-by-ID-to-mutiple-pipe-delimited-text-files/m-p/218256#M40209</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am fairly new to SAS and have been trying to figure of how to export a dataset into multiple pipe delimited text files based on the field PPG ID.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Lets assume my input dataset named &lt;STRONG&gt;&lt;EM&gt;stars_report_in&lt;/EM&gt;&lt;/STRONG&gt; is like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" style="border: 1px solid rgb(0, 0, 0); width: 100%;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;PPG ID&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;Member ID&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Member Name&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Cycle End Date&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;1011&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;123&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;David Thorne&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;04/07/2015&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;1011&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;234&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Macy Davis&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;TABLE border="1" class="jiveBorder" style="border: 1px solid #000000; width: 100%;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;04/07/2015&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;5674&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;567&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Deanna Summers&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;TABLE border="1" class="jiveBorder" style="border: 1px solid #000000; width: 100%;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;04/07/2015&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;5674&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;789&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Tabitha Adams&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;TABLE border="1" class="jiveBorder" style="border: 1px solid #000000; width: 100%;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;04/07/2015&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want text files created with file naming convention like this: &amp;lt;PPG ID&amp;gt;_Report_&amp;lt;Cycle End Date&amp;gt;.txt.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So first text file generated will be named &lt;STRONG&gt;&lt;EM&gt;1011_Report_04072015.txt&lt;/EM&gt;&lt;/STRONG&gt; and will have data in pipe delimited format like this&lt;/P&gt;&lt;P&gt;1011|123|David Thorne|04/07/2015&lt;/P&gt;&lt;P&gt;1011|234|Macy Davis|&lt;SPAN style="font-size: 13.3333330154419px;"&gt;04/07/2015&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Second text file will be named &lt;STRONG&gt;&lt;EM&gt;5674&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;&lt;STRONG&gt;&lt;EM&gt;_Report_04072015.txt&lt;/EM&gt; &lt;/STRONG&gt;and will contain data in pipe delimited format like this below&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;5674|567|Deanna Summers|&lt;SPAN style="font-size: 13.3333330154419px;"&gt;04/07/2015&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;5674|789|Tabitha Adams|&lt;SPAN style="font-size: 13.3333330154419px;"&gt;04/07/2015&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;,pipe_delimited&lt;/P&gt;&lt;P&gt;and so on. Any help on this would be really appreciated.&amp;nbsp; I use SAS EG 7.1 to write all my code. &lt;/P&gt;&lt;P&gt;Thanks!!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Apr 2015 17:32:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Export-dataset-by-ID-to-mutiple-pipe-delimited-text-files/m-p/218256#M40209</guid>
      <dc:creator>lathabrewer</dc:creator>
      <dc:date>2015-04-09T17:32:33Z</dc:date>
    </item>
    <item>
      <title>Re: Export dataset by ID to mutiple pipe delimited text files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Export-dataset-by-ID-to-mutiple-pipe-delimited-text-files/m-p/225191#M40406</link>
      <description>&lt;P&gt;You'll need to explicitly write your export in a data _null_ step but then you can use the FILEVAR option to split the files automatically.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's an example based on the SASHELP.CARS dataset. &amp;nbsp;Note the DLM option used to specify the delimiter and that the header names are explicitly defined.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SORT DATA=SASHELP.CARS OUT=CARS;
BY make;
RUN;


DATA _NULL_;

SET cars; *Dataset to be exported;
BY make; *Variable that file is to be split on;

*Create path to file that is to be exported;
if first.make then out_file=cats('C:\_localdata\temp\', trim(make), ".txt");

file temp filevar=out_file dlm='|' dsd;

*If first value of make then output column names;
if first.make then 
put 'Make|Model|MPG_HIGHWAY|MPG_CITY';

*Output variables;
put make model mpg_highway mpg_city;

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 11 Sep 2015 15:42:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Export-dataset-by-ID-to-mutiple-pipe-delimited-text-files/m-p/225191#M40406</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-09-11T15:42:27Z</dc:date>
    </item>
  </channel>
</rss>

