<?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 How do I Export csv file with blanks in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-Export-csv-file-with-blanks/m-p/588284#M168105</link>
    <description>&lt;P&gt;Hello there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to export a sas file as csv file in the latest SAS EG Version.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The table has 4 columns (number, charc, date1, date2).[number as int, charc as character, date1&amp;amp;date2 as date]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The charc-column contains numbers from 0 to 20 (1,2,3,...,10,...15,...20) and as the table needs to the same logical record length for every row for further processing, I wanted to export all one digit numbers as 'blankNUMBER', e.g: blank0, blank1, blank2, and so on.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Number;Charc;Date1;Date2&lt;/P&gt;&lt;P&gt;123456; 0;2019-01:2019-02&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;123456;10;2019-01;2019-02&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;

create table TABLE_1 as
select number,
case when charc lt 10 then cat(' ',charc)
else put(charc,2.)
end as charc,

date1,

date2

from TABLE_2;
quit;


filename csv "path...TABLE_1_Export.csv";

data _null_;

set TABLE_1;
file csv dlm=';';

if _n_ eq 1 then

PUT @1 'number;charc;date1;date2';

PUT number :$10.

charc :$char2.

date1 :EURDFDD10.

date2 :EURDFDD10.;

run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Unfortunately, the blank in the cat-function is not visible in the output. However, when I change the blank to a tab (by using '09'x I think) it's working, but a tabulator does not work for me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Are single blanks not possible to process while exporting to csv or am I missing sth. important in my code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance and have a great day,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Lukas&lt;/P&gt;</description>
    <pubDate>Thu, 12 Sep 2019 15:04:19 GMT</pubDate>
    <dc:creator>halu</dc:creator>
    <dc:date>2019-09-12T15:04:19Z</dc:date>
    <item>
      <title>How do I Export csv file with blanks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-Export-csv-file-with-blanks/m-p/588284#M168105</link>
      <description>&lt;P&gt;Hello there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to export a sas file as csv file in the latest SAS EG Version.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The table has 4 columns (number, charc, date1, date2).[number as int, charc as character, date1&amp;amp;date2 as date]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The charc-column contains numbers from 0 to 20 (1,2,3,...,10,...15,...20) and as the table needs to the same logical record length for every row for further processing, I wanted to export all one digit numbers as 'blankNUMBER', e.g: blank0, blank1, blank2, and so on.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Number;Charc;Date1;Date2&lt;/P&gt;&lt;P&gt;123456; 0;2019-01:2019-02&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;123456;10;2019-01;2019-02&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;

create table TABLE_1 as
select number,
case when charc lt 10 then cat(' ',charc)
else put(charc,2.)
end as charc,

date1,

date2

from TABLE_2;
quit;


filename csv "path...TABLE_1_Export.csv";

data _null_;

set TABLE_1;
file csv dlm=';';

if _n_ eq 1 then

PUT @1 'number;charc;date1;date2';

PUT number :$10.

charc :$char2.

date1 :EURDFDD10.

date2 :EURDFDD10.;

run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Unfortunately, the blank in the cat-function is not visible in the output. However, when I change the blank to a tab (by using '09'x I think) it's working, but a tabulator does not work for me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Are single blanks not possible to process while exporting to csv or am I missing sth. important in my code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance and have a great day,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Lukas&lt;/P&gt;</description>
      <pubDate>Thu, 12 Sep 2019 15:04:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-Export-csv-file-with-blanks/m-p/588284#M168105</guid>
      <dc:creator>halu</dc:creator>
      <dc:date>2019-09-12T15:04:19Z</dc:date>
    </item>
    <item>
      <title>Re: How do I Export csv file with blanks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-Export-csv-file-with-blanks/m-p/588286#M168106</link>
      <description>&lt;P&gt;Please show examples of the type of file you want to create. Make sure to use the Insert Code button on the editor menu so you get a pop-up box to paste in the example lines and they will not get mangled by the Forum software.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A delimited file (like a CSV file or the semi-colon delimited file in your quesiton) should NOT have fixed length records (or fixed length fields).&amp;nbsp; That is just the nature of the beast.&amp;nbsp;Note that normal readers of CSV files will ignore the leading/trailing spaces in the values anyway. SAS will definitely do that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps you just want to create a fixed column file and stuff in some commas (or semi-colons)?&lt;/P&gt;
&lt;P&gt;Perhaps something like this in a DATA step?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;put Number 6. ';' Charc $char2. ';' Date1 EURDFDD10. ';' Date2 EURDFDD10. ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Why does you example line show only 7 characters for the dates if you want to use a format with a width of 10?&lt;/P&gt;</description>
      <pubDate>Thu, 12 Sep 2019 15:14:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-Export-csv-file-with-blanks/m-p/588286#M168106</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-09-12T15:14:30Z</dc:date>
    </item>
  </channel>
</rss>

