<?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: exporting multiple data in a library in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/exporting-multiple-data-in-a-library/m-p/107979#M22446</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Awesome!&lt;/P&gt;&lt;P&gt;Thank you very much! I learn lots of things about SAS every time I ask for help here!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 16 Apr 2013 04:08:30 GMT</pubDate>
    <dc:creator>jhhuh</dc:creator>
    <dc:date>2013-04-16T04:08:30Z</dc:date>
    <item>
      <title>exporting multiple data in a library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/exporting-multiple-data-in-a-library/m-p/107974#M22441</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I found an SAS code which can export multiple sas files in a library. &lt;/P&gt;&lt;P&gt;Even though the code generally works fine, but there is a minor issue, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The name of exported files have trailing blanks&lt;/P&gt;&lt;P&gt;(such as.. when the name of sas data is "datatobeused", the name of exported file is "datatobeused&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; .csv" )&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;, &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;so I need to clean them before I use those files with other statistical packages. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;But the problem is that there are more than hundreds files that I need to clean... I hesitate to do it..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to find a problem with the code and use it. &lt;/P&gt;&lt;P&gt;Can anyone find which part should be corrected? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance! &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LIBNAME Test "/home/usr/jh/a/";&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%MACRO Convert2DTA(Libname);&amp;nbsp; &lt;/P&gt;&lt;P&gt;DATA MEMBERS;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;SET SASHELP.VMEMBER(WHERE=(LIBNAME = "&amp;amp;Libname"));&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt; RETAIN OBS 0;&amp;nbsp; &lt;/P&gt;&lt;P&gt; OBS = OBS+1;&amp;nbsp; &lt;/P&gt;&lt;P&gt; KEEP MEMNAME OBS;&amp;nbsp; &lt;/P&gt;&lt;P&gt;RUN;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC SQL;&amp;nbsp; &lt;/P&gt;&lt;P&gt;SELECT MIN(OBS) INTO :MIN&amp;nbsp; &lt;/P&gt;&lt;P&gt;FROM MEMBERS;&amp;nbsp; &lt;/P&gt;&lt;P&gt;QUIT;&amp;nbsp; &lt;/P&gt;&lt;P&gt;PROC SQL;&amp;nbsp; &lt;/P&gt;&lt;P&gt;SELECT MAX(OBS) INTO :MAX&amp;nbsp; &lt;/P&gt;&lt;P&gt;FROM MEMBERS;&amp;nbsp; &lt;/P&gt;&lt;P&gt;QUIT;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%Local D;&amp;nbsp; &lt;/P&gt;&lt;P&gt; %DO D = &amp;amp;MIN %TO &amp;amp;MAX;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; PROC SQL;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; SELECT COMPRESS(MEMNAME) INTO: Table&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; FROM MEMBERS&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; WHERE OBS=&amp;amp;D;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; QUIT;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; PROC EXPORT DBMS=csv DATA=&amp;amp;Libname..&amp;amp;Table&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; OUTFILE="/home/usr/jh/b/&amp;amp;Table..csv";&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; RUN;&amp;nbsp; &lt;/P&gt;&lt;P&gt;%END;&amp;nbsp; &lt;/P&gt;&lt;P&gt;%MEND;&amp;nbsp; &lt;/P&gt;&lt;P&gt;%Convert2DTA(TEST);&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 14 Apr 2013 21:32:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/exporting-multiple-data-in-a-library/m-p/107974#M22441</guid>
      <dc:creator>jhhuh</dc:creator>
      <dc:date>2013-04-14T21:32:39Z</dc:date>
    </item>
    <item>
      <title>Re: exporting multiple data in a library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/exporting-multiple-data-in-a-library/m-p/107975#M22442</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Try this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; PROC SQL;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; SELECT strip(COMPRESS(MEMNAME)) INTO: Table&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; FROM MEMBERS&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; WHERE OBS=&amp;amp;D;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; QUIT;&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Apr 2013 05:25:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/exporting-multiple-data-in-a-library/m-p/107975#M22442</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2013-04-15T05:25:40Z</dc:date>
    </item>
    <item>
      <title>Re: exporting multiple data in a library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/exporting-multiple-data-in-a-library/m-p/107976#M22443</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;PROC EXPORT DBMS=csv DATA=&amp;amp;Libname..&amp;amp;Table&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; OUTFILE="/home/usr/jh/b/&lt;STRONG&gt;%cmpres(&lt;/STRONG&gt;&amp;amp;Table&lt;STRONG&gt;)&lt;/STRONG&gt;.csv";&amp;nbsp; &lt;/P&gt;&lt;P&gt;RUN;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;would work as well.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Apr 2013 08:09:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/exporting-multiple-data-in-a-library/m-p/107976#M22443</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2013-04-15T08:09:15Z</dc:date>
    </item>
    <item>
      <title>Re: exporting multiple data in a library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/exporting-multiple-data-in-a-library/m-p/107977#M22444</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;dio you want us to fix the problem that creates the trailing balnks, or rename the CSV files after they are named like that?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Apr 2013 22:15:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/exporting-multiple-data-in-a-library/m-p/107977#M22444</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2013-04-15T22:15:47Z</dc:date>
    </item>
    <item>
      <title>Re: exporting multiple data in a library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/exporting-multiple-data-in-a-library/m-p/107978#M22445</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The spaces are being created because of the way that you a putting the member name into the macro variable using PROC SQL.&amp;nbsp; Add the SEPARATED BY clause and the trailing spaces will not be generated.&amp;nbsp; In SAS 9.3 there is an option to trim the spaces without using separated by.&amp;nbsp; You should also add the NOPRINT option to prevent PROC SQL from generating a page of output for every member name you pull from the dataset.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;PROC SQL &lt;STRONG&gt;NOPRINT&lt;/STRONG&gt; ; &lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; SELECT&lt;STRONG&gt; MEMNAME&lt;/STRONG&gt; INTO :Table &lt;STRONG&gt;SEPARATED BY ' '&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; FROM MEMBERS &lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; WHERE OBS=&amp;amp;D; &lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; QUIT; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can also easily remove the trailing (and leading) spaces from a macro variable by just assigning it back to itself.&lt;/P&gt;&lt;P&gt;%LET TABLE=&amp;amp;TABLE;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Apr 2013 23:09:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/exporting-multiple-data-in-a-library/m-p/107978#M22445</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-04-15T23:09:41Z</dc:date>
    </item>
    <item>
      <title>Re: exporting multiple data in a library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/exporting-multiple-data-in-a-library/m-p/107979#M22446</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Awesome!&lt;/P&gt;&lt;P&gt;Thank you very much! I learn lots of things about SAS every time I ask for help here!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Apr 2013 04:08:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/exporting-multiple-data-in-a-library/m-p/107979#M22446</guid>
      <dc:creator>jhhuh</dc:creator>
      <dc:date>2013-04-16T04:08:30Z</dc:date>
    </item>
  </channel>
</rss>

