<?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: Column header truncated when exporting to csv / Export large column header in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Column-header-truncated-when-exporting-to-csv-Export-large/m-p/656224#M196768</link>
    <description>&lt;P&gt;If you work with&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options validvarname=v7;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;set, you don't need the CATS() and QUOTE() functions, because you can't have blanks in variable names.&lt;/P&gt;</description>
    <pubDate>Wed, 10 Jun 2020 08:40:08 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2020-06-10T08:40:08Z</dc:date>
    <item>
      <title>Column header truncated when exporting to csv / Export large column header</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Column-header-truncated-when-exporting-to-csv-Export-large/m-p/655586#M196686</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to export to the CSV format a SAS dataset with a large number of columns (~2200) with a total length of around 42000 characters when all column titles concatened. The output final CSV file doesn't exceed 400MB because of a low number of rows.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;But when I open my CSV file, I see that more than 300 column names are missing. &lt;/EM&gt;&lt;STRONG&gt;How is that possible ? Would you know how to fix it please?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;More details :&lt;/U&gt;&lt;/P&gt;&lt;P&gt;-I've used a proc export to export as CSV.&lt;/P&gt;&lt;P&gt;-When I use a proc export to output a XLSX file, I don't get this problem.&lt;/P&gt;&lt;P&gt;-It seems that the problem is the total length of the concatened column names since it works well for the other rows which are shorter (when all concatened).&lt;/P&gt;&lt;P&gt;-It is like I need to set a&amp;nbsp;&lt;SPAN&gt;LRECL&amp;nbsp;option to a higher limit, but it doesn't exist in a proc export.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you very much in advance for your help.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Best regards&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jun 2020 16:35:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Column-header-truncated-when-exporting-to-csv-Export-large/m-p/655586#M196686</guid>
      <dc:creator>Olscream</dc:creator>
      <dc:date>2020-06-09T16:35:40Z</dc:date>
    </item>
    <item>
      <title>Re: Column header truncated when exporting to csv / Export large column header</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Column-header-truncated-when-exporting-to-csv-Export-large/m-p/655587#M196687</link>
      <description>Show your code. &lt;BR /&gt;Have you tried a data step and explicitly setting the record length?&lt;BR /&gt;How are you checking the CSV, via a text editor or Excel? FYI - don't use Excel it can sometimes not parse records correctly causing issues.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 09 Jun 2020 16:39:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Column-header-truncated-when-exporting-to-csv-Export-large/m-p/655587#M196687</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-06-09T16:39:28Z</dc:date>
    </item>
    <item>
      <title>Re: Column header truncated when exporting to csv / Export large column header</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Column-header-truncated-when-exporting-to-csv-Export-large/m-p/655590#M196688</link>
      <description>&lt;P&gt;The code created by proc export tries to write the header as one string, which exceeds the maximum length of character values (32767).&lt;/P&gt;
&lt;P&gt;Locate the header in the code, and split it to two separate put statements with a line hold (@) in the first.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jun 2020 16:43:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Column-header-truncated-when-exporting-to-csv-Export-large/m-p/655590#M196688</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-06-09T16:43:11Z</dc:date>
    </item>
    <item>
      <title>Re: Column header truncated when exporting to csv / Export large column header</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Column-header-truncated-when-exporting-to-csv-Export-large/m-p/655593#M196690</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*Create demo data;
data class;
	set sashelp.class;
	label age='Age, Years' weight = 'Weight(lbs)' height='Height, inches';
run;

proc sql noprint;
create table temp as
select name as _name_, label as _label_
from dictionary.columns
where libname="WORK" and upcase(memname)="CLASS";
select cats(quote(name),"n") into :varList separated by ' '
from dictionary.columns
where libname="WORK" and upcase(memname)="CLASS";
quit;

data _null_;
file "&amp;amp;sasforum.\datasets\TwoLinesHeader.csv" dsd lrecl = 40000;
set class;
if _n_ = 1 then do;
do until(eof);
    set temp end=eof;
    put _name_ @;
    end;
put;

put (&amp;amp;varList) (:);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Modified version of this which prints names and labels. I removed the labels section.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://gist.github.com/statgeek/ae153e40af0d35dce02d1c8102ff3b94" target="_blank"&gt;https://gist.github.com/statgeek/ae153e40af0d35dce02d1c8102ff3b94&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jun 2020 16:48:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Column-header-truncated-when-exporting-to-csv-Export-large/m-p/655593#M196690</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-06-09T16:48:05Z</dc:date>
    </item>
    <item>
      <title>Re: Column header truncated when exporting to csv / Export large column header</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Column-header-truncated-when-exporting-to-csv-Export-large/m-p/656140#M196759</link>
      <description>Could you show a snippet of code in order to do that please ?</description>
      <pubDate>Wed, 10 Jun 2020 08:02:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Column-header-truncated-when-exporting-to-csv-Export-large/m-p/656140#M196759</guid>
      <dc:creator>Olscream</dc:creator>
      <dc:date>2020-06-10T08:02:13Z</dc:date>
    </item>
    <item>
      <title>Re: Column header truncated when exporting to csv / Export large column header</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Column-header-truncated-when-exporting-to-csv-Export-large/m-p/656163#M196761</link>
      <description>&lt;P&gt;Thanks for your answer. However it could work but I got several errors when trying it, the first one being :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc sql noprint;&lt;BR /&gt;select cats(quote(name),"n")into : varList separated by ' '
from dictionary.columns
where LIBNAME = upcase("WORK")
and MEMNAME = upcase("My_Table");
quit;
%put &amp;amp;varList.;&lt;/PRE&gt;&lt;LI-SPOILER&gt;ERROR: The length of the value of the macro variable VARLIST (65540) exceeds the maximum length (65534). The value has been&lt;BR /&gt;truncated to 65534 characters.&lt;/LI-SPOILER&gt;&lt;P&gt;But on the other hand, it works when removing the CATS and QUOTE functions such as :&lt;/P&gt;&lt;PRE&gt;proc sql noprint;
select name into : varList separated by ' '
from dictionary.columns
where LIBNAME = upcase("WORK")
and MEMNAME = upcase("My_Table");
quit;
%put &amp;amp;varList.;&lt;/PRE&gt;&lt;LI-SPOILER&gt;%put &amp;amp;varList.;&lt;BR /&gt;Col1 Col2 Col3 ...&lt;/LI-SPOILER&gt;&lt;P&gt;Would you know how to "overpass" this limit please ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jun 2020 08:09:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Column-header-truncated-when-exporting-to-csv-Export-large/m-p/656163#M196761</guid>
      <dc:creator>Olscream</dc:creator>
      <dc:date>2020-06-10T08:09:55Z</dc:date>
    </item>
    <item>
      <title>Re: Column header truncated when exporting to csv / Export large column header</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Column-header-truncated-when-exporting-to-csv-Export-large/m-p/656175#M196762</link>
      <description>&lt;P&gt;I do a simple export as following :&lt;/P&gt;&lt;PRE&gt;proc export data=My_Table
dbms=csv
outfile="&amp;amp;month_My_Table.csv"
replace;
run;&lt;/PRE&gt;&lt;P&gt;&amp;amp;month is a number like 201501.&lt;/P&gt;&lt;P&gt;I've noticed the error thanks Microsoft Excel 2016 but also in another programming language.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jun 2020 08:13:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Column-header-truncated-when-exporting-to-csv-Export-large/m-p/656175#M196762</guid>
      <dc:creator>Olscream</dc:creator>
      <dc:date>2020-06-10T08:13:33Z</dc:date>
    </item>
    <item>
      <title>Re: Column header truncated when exporting to csv / Export large column header</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Column-header-truncated-when-exporting-to-csv-Export-large/m-p/656224#M196768</link>
      <description>&lt;P&gt;If you work with&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options validvarname=v7;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;set, you don't need the CATS() and QUOTE() functions, because you can't have blanks in variable names.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jun 2020 08:40:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Column-header-truncated-when-exporting-to-csv-Export-large/m-p/656224#M196768</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-06-10T08:40:08Z</dc:date>
    </item>
  </channel>
</rss>

