<?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: Upper case/lower case problem when exporting files in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Upper-case-lower-case-problem-when-exporting-files/m-p/768597#M243795</link>
    <description>It works! Thank you very much!!</description>
    <pubDate>Mon, 20 Sep 2021 16:05:35 GMT</pubDate>
    <dc:creator>DiG</dc:creator>
    <dc:date>2021-09-20T16:05:35Z</dc:date>
    <item>
      <title>Upper case/lower case problem when exporting files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Upper-case-lower-case-problem-when-exporting-files/m-p/768568#M243787</link>
      <description>&lt;P&gt;Good day!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am facing a small problem in my SAS code that I can't figure out. The macro below&amp;nbsp;exports all SAS datasets in&amp;nbsp;library MYLIB&amp;nbsp;into csv files. It works seamlessly but the output csv file names come out all uppercase. I need them to be lowercase. Could you please tell me how to achieve it?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;Libname&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; MYLIB &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;"C:\mypath"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;%MACRO&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt; Convert2CSV(LIBNAME); &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008000"&gt;/*do not change it!*/&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data members;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt; set sashelp.vmember(where=(LIBNAME = &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;"&amp;amp;Libname"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;)); &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008000"&gt;/*do not change it!*/&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt; retain obs &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt; obs = obs+&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&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;/P&gt;
&lt;P&gt;select min(obs) into :min&lt;/P&gt;
&lt;P&gt;from members;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;select max(obs) into :max&lt;/P&gt;
&lt;P&gt;from members;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%Local&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; d;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; d = &amp;amp;min &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%to&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;max;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;select compress(memname) into: Table&lt;/P&gt;
&lt;P&gt;from members&lt;/P&gt;
&lt;P&gt;where obs=&amp;amp;d;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; tbl = %trim(&amp;amp;Table);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;　&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt; proc export dbms=csv data=&amp;amp;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;Libname.&lt;STRONG&gt;.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;amp;Table&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt; outfile=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;"C:\mypath\output\&amp;amp;tbl..csv"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%end&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;%mend&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;Convert2CSV&lt;/I&gt;&lt;/STRONG&gt;(MYLIB);&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Sep 2021 14:17:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Upper-case-lower-case-problem-when-exporting-files/m-p/768568#M243787</guid>
      <dc:creator>DiG</dc:creator>
      <dc:date>2021-09-20T14:17:50Z</dc:date>
    </item>
    <item>
      <title>Re: Upper case/lower case problem when exporting files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Upper-case-lower-case-problem-when-exporting-files/m-p/768574#M243789</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc export dbms=csv data=&amp;amp;Libname..&amp;amp;Table outfile="&lt;SPAN&gt;C:\mypath\output&lt;/SPAN&gt;\%lowcase(&amp;amp;tbl).csv";&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 20 Sep 2021 14:38:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Upper-case-lower-case-problem-when-exporting-files/m-p/768574#M243789</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-09-20T14:38:13Z</dc:date>
    </item>
    <item>
      <title>Re: Upper case/lower case problem when exporting files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Upper-case-lower-case-problem-when-exporting-files/m-p/768581#M243791</link>
      <description>&lt;P&gt;Just store the lowcase name into the macro variable.&lt;/P&gt;
&lt;P&gt;You don't want to run COMPRESS() on the name.&amp;nbsp; If you don't want the macro variable to have trailing spaces use the TRIMMED keyword.&amp;nbsp; If you are using VALIDMEMNAME=EXTEND then you might want to use NLITERAL() for the TABLE macro variable.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
  select nliteral(memname), lowcase(memname)
    into :Table , :tbl trimmed
    from members
    where obs=&amp;amp;d
  ;
quit;

proc export dbms=csv data=&amp;amp;Libname..&amp;amp;Table
  outfile="C:\mypath\output\&amp;amp;tbl..csv" replace
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Sep 2021 14:57:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Upper-case-lower-case-problem-when-exporting-files/m-p/768581#M243791</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-09-20T14:57:37Z</dc:date>
    </item>
    <item>
      <title>Re: Upper case/lower case problem when exporting files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Upper-case-lower-case-problem-when-exporting-files/m-p/768597#M243795</link>
      <description>It works! Thank you very much!!</description>
      <pubDate>Mon, 20 Sep 2021 16:05:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Upper-case-lower-case-problem-when-exporting-files/m-p/768597#M243795</guid>
      <dc:creator>DiG</dc:creator>
      <dc:date>2021-09-20T16:05:35Z</dc:date>
    </item>
    <item>
      <title>Re: Upper case/lower case problem when exporting files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Upper-case-lower-case-problem-when-exporting-files/m-p/768599#M243796</link>
      <description>Thank you for your comments Tom.&lt;BR /&gt;PaigeMiller above proposed a quick&amp;amp;simple solution too.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 20 Sep 2021 16:09:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Upper-case-lower-case-problem-when-exporting-files/m-p/768599#M243796</guid>
      <dc:creator>DiG</dc:creator>
      <dc:date>2021-09-20T16:09:05Z</dc:date>
    </item>
    <item>
      <title>Re: Upper case/lower case problem when exporting files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Upper-case-lower-case-problem-when-exporting-files/m-p/768610#M243802</link>
      <description>&lt;P&gt;Note that adding a patch, %lowcase(),&amp;nbsp; on top of a patch , %trim(),&amp;nbsp; on top of a patch, compress(), is going to make your code harder to understand and debug.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could also just get rid of all of the macro logic.&amp;nbsp; It is much easier to debug SAS code instead of macro code.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro Convert2CSV(LIBNAME); 
data members;
  set sashelp.vmember(where=(LIBNAME = %upcase("&amp;amp;Libname"));
  obs+1;
  length filename $200;
  filename=quote(cats('C:\mypath\output\',lowcase(memname),'.csv'));
  call execute(catx(' '
   ,'proc export dbms=csv data=',catx('.',libname,nliteral(table))
   ,'outfile=',filename,';run;'
  ));
  keep obs libname memname filename;
run;
%mend Convert2CSV;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Sep 2021 17:09:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Upper-case-lower-case-problem-when-exporting-files/m-p/768610#M243802</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-09-20T17:09:19Z</dc:date>
    </item>
  </channel>
</rss>

