<?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: Proc Export: Removing spaces in generated file in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-Export-Removing-spaces-in-generated-file/m-p/568333#M159961</link>
    <description>Thanks KurtBremser!&lt;BR /&gt;&lt;BR /&gt;This did the trick &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
    <pubDate>Mon, 24 Jun 2019 10:18:31 GMT</pubDate>
    <dc:creator>sg16773</dc:creator>
    <dc:date>2019-06-24T10:18:31Z</dc:date>
    <item>
      <title>Proc Export: Removing spaces in generated file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Export-Removing-spaces-in-generated-file/m-p/568314#M159953</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have multiple sas datsets(~30) present in a directory and need to convert all these into text files.&amp;nbsp; I am using the code below for same:&lt;/P&gt;&lt;P&gt;=====================================================&lt;/P&gt;&lt;P&gt;LIBNAME Test "D:\";&lt;/P&gt;&lt;P&gt;%MACRO Convert2CSV(Libname);&lt;/P&gt;&lt;P&gt;DATA MEMBERS;&lt;BR /&gt;SET SASHELP.VMEMBER(WHERE=(LIBNAME = "&amp;amp;Libname"));&lt;/P&gt;&lt;P&gt;RETAIN OBS 0;&lt;BR /&gt;OBS = OBS+1;&lt;/P&gt;&lt;P&gt;KEEP MEMNAME OBS;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;BR /&gt;SELECT MIN(OBS) INTO :MIN&lt;BR /&gt;FROM MEMBERS;&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;BR /&gt;SELECT MAX(OBS) INTO :MAX&lt;BR /&gt;FROM MEMBERS;&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;P&gt;%Local D;&lt;/P&gt;&lt;P&gt;%DO D = &amp;amp;MIN %TO &amp;amp;MAX;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;/P&gt;&lt;P&gt;SELECT COMPRESS(MEMNAME) INTO: Table&lt;BR /&gt;FROM MEMBERS&lt;BR /&gt;WHERE OBS=&amp;amp;D;&lt;/P&gt;&lt;P&gt;QUIT;&lt;/P&gt;&lt;P&gt;PROC EXPORT DATA=&amp;amp;Libname..&amp;amp;Table DBMS=dlm replace&lt;BR /&gt;OUTFILE="D:\_today\&amp;amp;Table..txt";&lt;BR /&gt;delimiter="|";&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;%END;&lt;/P&gt;&lt;P&gt;%MEND;&lt;/P&gt;&lt;P&gt;%Convert2CSV(TEST);&lt;/P&gt;&lt;P&gt;==================================================================&lt;/P&gt;&lt;P&gt;Note: I have leveraged this code from (&lt;A href="https://communities.sas.com/t5/SAS-Programming/Export-multiple-tables-from-SAS-to-csv/td-p/27090" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/SAS-Programming/Export-multiple-tables-from-SAS-to-csv/td-p/27090&lt;/A&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Issue: The generated text files have spaces in the name. For eg: 'myfile.sas7bat' gets converted to 'myfile&amp;nbsp; &amp;nbsp; .txt'&lt;/P&gt;&lt;P&gt;Just a hunch but I think the generated filenames are of fixed length. Therefore to meet the length, SAS is introducing spaces. How do avoid this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ask: I need help in removing the spaces from the generated file name. I have tried using the Trim function but it doesn't seems to be working.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jun 2019 08:50:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Export-Removing-spaces-in-generated-file/m-p/568314#M159953</guid>
      <dc:creator>sg16773</dc:creator>
      <dc:date>2019-06-24T08:50:38Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Export: Removing spaces in generated file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Export-Removing-spaces-in-generated-file/m-p/568316#M159954</link>
      <description>&lt;P&gt;Why don't you just do it in one data step that creates the exports with call execute?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
set sashelp.vmember (where=(libname = "TEST"));
call execute('
  proc export
    data=' || strip(memname) || '
    dbms=dlm
    replace
    outfile="D:\_today\' || strip(lowcase(memname)) || '.txt"
  ;
  delimiter="|";
  run;
';
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 24 Jun 2019 08:56:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Export-Removing-spaces-in-generated-file/m-p/568316#M159954</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-06-24T08:56:38Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Export: Removing spaces in generated file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Export-Removing-spaces-in-generated-file/m-p/568320#M159955</link>
      <description>&lt;P&gt;Hi KurtBremser,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your response. I tried the code you suggested but I am getting the following error(screenshot below). May be the code is not able to search the dataset in the defined library("TEST").&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Apologies for the silly questions but I am very new to SAS and trying to learn the language.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/30485i586FCA420B757DAB/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jun 2019 09:10:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Export-Removing-spaces-in-generated-file/m-p/568320#M159955</guid>
      <dc:creator>sg16773</dc:creator>
      <dc:date>2019-06-24T09:10:30Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Export: Removing spaces in generated file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Export-Removing-spaces-in-generated-file/m-p/568324#M159957</link>
      <description>&lt;P&gt;I forgot to add the libname in my call execute. Expand the call execute like this.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;call execute("
  proc export
    data=test." || strip(memname) || "
    dbms=dlm
    replace
    outfile='D:\_today\" || strip(lowcase(memname)) || ".txt'
  ;
  delimiter='|';
  run;
";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that I also changed the usage of single and double quotes, to facilitate the use of a macro variable/parameter if you later want to wrap the whole data step into a macro definition for easier reuse.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jun 2019 09:29:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Export-Removing-spaces-in-generated-file/m-p/568324#M159957</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-06-24T09:29:43Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Export: Removing spaces in generated file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Export-Removing-spaces-in-generated-file/m-p/568333#M159961</link>
      <description>Thanks KurtBremser!&lt;BR /&gt;&lt;BR /&gt;This did the trick &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Mon, 24 Jun 2019 10:18:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Export-Removing-spaces-in-generated-file/m-p/568333#M159961</guid>
      <dc:creator>sg16773</dc:creator>
      <dc:date>2019-06-24T10:18:31Z</dc:date>
    </item>
  </channel>
</rss>

