<?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: Eport to CSV. Issue with null values. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Eport-to-CSV-Issue-with-null-values/m-p/237177#M268251</link>
    <description>&lt;P&gt;Ah, so its the extra space thats the problem, this below should solve that. &amp;nbsp;However do bear in mind my other points about delimiter - anyone looking at the file will expect CSV data which yours isn't.&lt;/P&gt;
&lt;PRE&gt;data test;
    col1='test';
    col2='';
    col3='"test" data';
run;
data _null_;
  set test;
  file "s:temp\rob\test.csv" dlm="," lrecl=32767;
  line=cats(col1,",",col2,",",col3);
  put line;
run;&lt;/PRE&gt;</description>
    <pubDate>Tue, 01 Dec 2015 15:20:21 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2015-12-01T15:20:21Z</dc:date>
    <item>
      <title>Eport to CSV. Issue with null values.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Eport-to-CSV-Issue-with-null-values/m-p/237154#M268248</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;I have a problem with exporting data into CSV file. When I'm trying to export data using DATA step it works fine, but it puts blank spaces when string is empty. This case can be fixed after I add DSD file option but another problem occurs, it's additional quotation marks. And I don't need them.&lt;BR /&gt;Data example:&lt;BR /&gt;options missing='';&lt;BR /&gt;data test;&lt;BR /&gt; a="";&lt;BR /&gt; b="sad";&lt;BR /&gt; c="";&lt;BR /&gt; d='"asd" asd';&lt;BR /&gt;run;&lt;BR /&gt;Export using data step:&lt;BR /&gt;data _null_;&lt;BR /&gt; set test;&lt;BR /&gt; FILE "....\test.csv" DLM="#" LRECL=32767;&lt;BR /&gt; PUT a b c d;&lt;BR /&gt;run;&lt;BR /&gt;I also tried PROC EXPORT but it works the same way as DATA STEP with DSD option.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Dec 2015 12:49:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Eport-to-CSV-Issue-with-null-values/m-p/237154#M268248</guid>
      <dc:creator>Yura2301</dc:creator>
      <dc:date>2015-12-01T12:49:18Z</dc:date>
    </item>
    <item>
      <title>Re: Eport to CSV. Issue with null values.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Eport-to-CSV-Issue-with-null-values/m-p/237157#M268249</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Firstly it is not recommend to use the file extension CSV = Comma Separated Variable file, when you are using a has symbol as a delimiter. &amp;nbsp;TBH its not a good idea to use a has as delimiter at all.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Secondly I am not sure what the question is in reference to. &amp;nbsp;In the example you provide, you explicitly add quotes into the text string:&lt;/P&gt;
&lt;P&gt;d='"asd" asd';&lt;/P&gt;
&lt;P&gt;Means that the variable d contains the string:&amp;nbsp;"asd" asd&lt;/P&gt;
&lt;P&gt;Which when written to the file, looks like that. &amp;nbsp;Are you saying you want to string quotes out from the variable, then just add in the datastep:&lt;/P&gt;
&lt;PRE&gt;data _null_;
  set test;
  file "s:temp\rob\test.csv" dlm="," lrecl=32767;
  d=compress(d,'"');  /* Single quote, double quote, single quote */
  put a b c d;
run;&lt;/PRE&gt;
&lt;P&gt;This will remove double quotes from your data.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Dec 2015 13:09:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Eport-to-CSV-Issue-with-null-values/m-p/237157#M268249</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-12-01T13:09:47Z</dc:date>
    </item>
    <item>
      <title>Re: Eport to CSV. Issue with null values.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Eport-to-CSV-Issue-with-null-values/m-p/237175#M268250</link>
      <description>&lt;P&gt;Sorry for this misunderstanding. Let me explain again.&lt;BR /&gt;I have input data like this. All character values. col2 is empty string and col3 contains quotation marks as a part of the string.&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/993iE89CDE69A7EC50DE/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="Untitled.png" title="Untitled.png" /&gt;&lt;/P&gt;
&lt;P&gt;You can use this script to generate this dataset:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
    col1='test';
    col2='';
    col3='"test" data';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I used following export script:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
    set test;
    FILE "....\test.csv" DLM="#" LRECL=32767;
    PUT col1 col2 col3;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I run my export script without DSD option and get this result (Blank space at col2 where string is empty):&lt;/P&gt;
&lt;PRE&gt;test# #"test" data&lt;/PRE&gt;
&lt;P&gt;I've also tried to use DSD option:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
    set test;
    FILE "....\test.csv" DLM="#" DSD LRECL=32767;
    PUT col1 col2 col3;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I've got the following result after I run my export script with DSD option (No space at col2 but additional quotation marks at col3):&lt;/P&gt;
&lt;PRE&gt;test##"""test"" data"&lt;/PRE&gt;
&lt;P&gt;The problem is that I need neither first nor second result. I need result the same as input data. Like this:&lt;/P&gt;
&lt;PRE&gt;test##"test" data&lt;/PRE&gt;
&lt;P&gt;Can you help me to reach this result?&lt;/P&gt;</description>
      <pubDate>Tue, 01 Dec 2015 15:09:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Eport-to-CSV-Issue-with-null-values/m-p/237175#M268250</guid>
      <dc:creator>Yura2301</dc:creator>
      <dc:date>2015-12-01T15:09:43Z</dc:date>
    </item>
    <item>
      <title>Re: Eport to CSV. Issue with null values.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Eport-to-CSV-Issue-with-null-values/m-p/237177#M268251</link>
      <description>&lt;P&gt;Ah, so its the extra space thats the problem, this below should solve that. &amp;nbsp;However do bear in mind my other points about delimiter - anyone looking at the file will expect CSV data which yours isn't.&lt;/P&gt;
&lt;PRE&gt;data test;
    col1='test';
    col2='';
    col3='"test" data';
run;
data _null_;
  set test;
  file "s:temp\rob\test.csv" dlm="," lrecl=32767;
  line=cats(col1,",",col2,",",col3);
  put line;
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 01 Dec 2015 15:20:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Eport-to-CSV-Issue-with-null-values/m-p/237177#M268251</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-12-01T15:20:21Z</dc:date>
    </item>
    <item>
      <title>Re: Eport to CSV. Issue with null values.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Eport-to-CSV-Issue-with-null-values/m-p/237367#M268252</link>
      <description>&lt;P&gt;Hi RW9,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for your answer.&lt;/P&gt;
&lt;P&gt;But I have one more issue that appeared with&amp;nbsp;your solution.&lt;/P&gt;
&lt;P&gt;I have a dataset that contains more columns. You can create it using this script.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
	col1 = 0;
	col2 = 1;
	col3 = 2;
	col4 = 3;
	col5 = '';
	col6 = 'ThisIsTestStringThatIsCuttedSomehow';
	col7 = '';
	col8 = 4567;
	col9 = 8;
	col10 = .;
	col11 = 'TestString';
	col12 = 9;
	col13 = 10;
	col14 = 'TestStringWith"Quotation"Marks';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So, if I use your solution it cuts out part of the string in column "col6".&lt;/P&gt;
&lt;P&gt;Funny thing is when I change value of the "col1" to something else except 0, string in "col6" will not be cutted.&lt;/P&gt;
&lt;P&gt;Below is the script that I used:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;option missing='';
data tmp1;
	length line $32767;
	set test;
	file "...\test.csv" dlm="," lrecl=32767;
	line = cats(col1,",",col2,",",col3,",",col4,",",col5,",",col6,",",col7,",",col8,",",col9,",",col10,",",col11,",",col12,",",col13,",",col14);
	put line;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Hopefully, you have some other solution or know how to fix that.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Dec 2015 14:03:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Eport-to-CSV-Issue-with-null-values/m-p/237367#M268252</guid>
      <dc:creator>Yura2301</dc:creator>
      <dc:date>2015-12-02T14:03:20Z</dc:date>
    </item>
    <item>
      <title>Re: Eport to CSV. Issue with null values.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Eport-to-CSV-Issue-with-null-values/m-p/237384#M268253</link>
      <description>&lt;P&gt;It is &amp;nbsp;because your length statement is invalid, lengths can only be $2000 max, the below works. &amp;nbsp;What I would say however is does the space really matter that much? &amp;nbsp;I just think your creating a lot of work for yourself over such a small matter. &amp;nbsp;You could simply do:&lt;/P&gt;
&lt;PRE&gt;data _null_;
	set test;
	file "s:\temp\rob\test.csv" dlm="," lrecl=32767;
	put (_all_) (~);
run;
&lt;/PRE&gt;
&lt;P&gt;The space doesn't really matter that much. &amp;nbsp;The reason that it comes out is strings are alway one space.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data test;
	col1 = 0;
	col2 = 1;
	col3 = 2;
	col4 = 3;
	col5 = '';
	col6 = 'ThisIsTestStringThatIsCuttedSomehow';
	col7 = '';
	col8 = 4567;
	col9 = 8;
	col10 = .;
	col11 = 'TestString';
	col12 = 9;
	col13 = 10;
	col14 = 'TestStringWith"Quotation"Marks';
run;

data _null_;
	length line $2000;
	set test;
	file "s:\temp\rob\test.csv" dlm="," lrecl=32767;
	line = cats(col1,",",col2,",",col3,",",col4,",",col5,",",col6,",",col7,",",col8,",",col9,",",col10,",",col11,",",col12,",",col13,",",col14);
	put line;
run;&lt;/PRE&gt;</description>
      <pubDate>Wed, 02 Dec 2015 14:48:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Eport-to-CSV-Issue-with-null-values/m-p/237384#M268253</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-12-02T14:48:40Z</dc:date>
    </item>
    <item>
      <title>Re: Eport to CSV. Issue with null values.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Eport-to-CSV-Issue-with-null-values/m-p/237414#M268254</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Line = catx(',', col1,col2,col3,col4 ..., col14);&amp;nbsp; /* I'm too lazy this morning to type out all the variable names*/&lt;/P&gt;</description>
      <pubDate>Wed, 02 Dec 2015 18:13:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Eport-to-CSV-Issue-with-null-values/m-p/237414#M268254</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-12-02T18:13:04Z</dc:date>
    </item>
    <item>
      <title>Re: Eport to CSV. Issue with null values.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Eport-to-CSV-Issue-with-null-values/m-p/237468#M268255</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16763"&gt;@Yura2301﻿&lt;/a&gt;&amp;nbsp;PROC EXPORT should give you what you're after without a lot of coding. It also deals with the quoting for csv's.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
PROC EXPORT DATA=work.test
  OUTFILE="c:\temp\test2.csv"
  REPLACE
  DBMS=CSV;
  PUTNAMES=NO;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 02 Dec 2015 21:15:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Eport-to-CSV-Issue-with-null-values/m-p/237468#M268255</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2015-12-02T21:15:05Z</dc:date>
    </item>
    <item>
      <title>Re: Eport to CSV. Issue with null values.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Eport-to-CSV-Issue-with-null-values/m-p/237538#M268256</link>
      <description>&lt;P&gt;Hi RW9,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It works because you lost "missing" option&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;option &lt;SPAN class="token function"&gt;missing&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;''&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;After you add this option, it will cut the "col6". Really don't know why is it so...&lt;/P&gt;</description>
      <pubDate>Thu, 03 Dec 2015 07:57:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Eport-to-CSV-Issue-with-null-values/m-p/237538#M268256</guid>
      <dc:creator>Yura2301</dc:creator>
      <dc:date>2015-12-03T07:57:12Z</dc:date>
    </item>
    <item>
      <title>Re: Eport to CSV. Issue with null values.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Eport-to-CSV-Issue-with-null-values/m-p/237539#M268257</link>
      <description>&lt;P&gt;I've tried already this way. "Catx" removes all missing strings. In my example it removes "col5" and "col7", so looks looks like this:&lt;/P&gt;
&lt;PRE&gt;0,1,2,3,ThisIsTestStringThatIsCuttedSomehow,4567,8,.,TestString,9,10,TestStringWith"Quotation"Marks&lt;/PRE&gt;
&lt;P&gt;It breaks the file struckture. And also if you add option missing='' it will cut the "col6"...&lt;/P&gt;</description>
      <pubDate>Thu, 03 Dec 2015 08:06:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Eport-to-CSV-Issue-with-null-values/m-p/237539#M268257</guid>
      <dc:creator>Yura2301</dc:creator>
      <dc:date>2015-12-03T08:06:43Z</dc:date>
    </item>
    <item>
      <title>Re: Eport to CSV. Issue with null values.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Eport-to-CSV-Issue-with-null-values/m-p/237541#M268258</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick﻿&lt;/a&gt;&amp;nbsp;this solution works fine except quotation marks. That's a string I have:&lt;/P&gt;
&lt;PRE&gt;TestStringWith"Quotation"Marks&lt;/PRE&gt;
&lt;P&gt;And what I've got:&lt;/P&gt;
&lt;PRE&gt;"TestStringWith""Quotation""Marks"&lt;/PRE&gt;
&lt;P&gt;But I'm really don't need these additional quotation marks.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Dec 2015 08:13:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Eport-to-CSV-Issue-with-null-values/m-p/237541#M268258</guid>
      <dc:creator>Yura2301</dc:creator>
      <dc:date>2015-12-03T08:13:46Z</dc:date>
    </item>
    <item>
      <title>Re: Eport to CSV. Issue with null values.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Eport-to-CSV-Issue-with-null-values/m-p/237546#M268259</link>
      <description>&lt;P&gt;No, I get exactly the same result with or without the missing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That being said though Patrick does raise a good point, why not just use proc export? &amp;nbsp;If you do that, and then import it again, the data is correct , i.e. your text string still has " " in it. &amp;nbsp;The reason is puts additional quotes around that is so that it can handle the quotes in the text. &amp;nbsp;So if you do this, you get the same input as output:&lt;/P&gt;
&lt;PRE&gt;data test;
	col1 = 0;
	col2 = 1;
	col3 = 2;
	col4 = 3;
	col5 = '';
	col6 = 'ThisIsTestStringThatIsCuttedSomehow';
	col7 = '';
	col8 = 4567;
	col9 = 8;
	col10 = .;
	col11 = 'TestString';
	col12 = 9;
	col13 = 10;
	col14 = 'TestStringWith"Quotation"Marks';
  output; output; output; output; output;
run;
PROC EXPORT DATA=work.test
  OUTFILE="s:\temp\rob\test2.csv"
  REPLACE
  DBMS=CSV;
  PUTNAMES=NO;
run;
proc import datafile="s:\temp\rob\test2.csv" out=test2;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Dec 2015 09:01:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Eport-to-CSV-Issue-with-null-values/m-p/237546#M268259</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-12-03T09:01:57Z</dc:date>
    </item>
    <item>
      <title>Re: Eport to CSV. Issue with null values.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Eport-to-CSV-Issue-with-null-values/m-p/237559#M268260</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9﻿&lt;/a&gt;&amp;nbsp;the problem is that I'm using CSV file not for import into SAS, I'm using it in other system, that's why I need so special result.&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="line-height: 20px;"&gt;I'll use you solution with CATS function without MISSING option and then just remove ",.," with regular expresion.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="line-height: 20px;"&gt;Thanks everybody for your answer.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Dec 2015 10:34:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Eport-to-CSV-Issue-with-null-values/m-p/237559#M268260</guid>
      <dc:creator>Yura2301</dc:creator>
      <dc:date>2015-12-03T10:34:29Z</dc:date>
    </item>
    <item>
      <title>Re: Eport to CSV. Issue with null values.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Eport-to-CSV-Issue-with-null-values/m-p/237560#M268261</link>
      <description>&lt;P&gt;Well, I am glad you have a solution. &amp;nbsp;The . is created because the variables are numeric. &amp;nbsp;You could just convert them to character. &amp;nbsp;As for the other system, it shouldn't matter to it if there is a space there, though I can understand it probably doesn't like "." as that is a SAS specific thing. &amp;nbsp;You could of course do:&lt;/P&gt;
&lt;P&gt;line=compress(cats(col1,col2,col3),".");&lt;/P&gt;
&lt;P&gt;To get rid of the dot, though as always, the cats string is doing an implicit conversion to character on your numeric values. &amp;nbsp;I advise against letting it guess this and put it in explicitly:&lt;/P&gt;
&lt;P&gt;line=compress(cats(put(col1,3.),put(col2,3.),col3),".");&lt;/P&gt;
&lt;P&gt;In the above you can set the format of the number to whatever you want, and its clear that it is number to character conversion.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Dec 2015 10:43:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Eport-to-CSV-Issue-with-null-values/m-p/237560#M268261</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-12-03T10:43:26Z</dc:date>
    </item>
  </channel>
</rss>

