<?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: How do I export to CSV without quotes for null values in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-do-I-export-to-CSV-without-quotes-for-null-values/m-p/575995#M75469</link>
    <description>&lt;P&gt;The period is showing because that is the default display character for a missing value.&lt;/P&gt;
&lt;P&gt;You can get single blank by using:&lt;/P&gt;
&lt;P&gt;Options missing=" ";&lt;/P&gt;
&lt;P&gt;prior to running that code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Better would &amp;nbsp;be to use Proc Export or the data export wizard to create CSV files&amp;nbsp;but numeric values do not normally have quotes and quotes would normally only be required for character values that contain commas in delimited files.&lt;/P&gt;
&lt;P&gt;If that is not acceptable then you are likely going tto&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And why do you say "with parenthesis around the data in each field, unless it's null," but show quotes???&lt;/P&gt;</description>
    <pubDate>Tue, 23 Jul 2019 22:27:15 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2019-07-23T22:27:15Z</dc:date>
    <item>
      <title>How do I export to CSV without quotes for null values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-do-I-export-to-CSV-without-quotes-for-null-values/m-p/575966#M75468</link>
      <description>&lt;P&gt;I have a dataset in SAS and I need that data in a csv file with parenthesis around the data in each field, unless it's null, then I need it to be completely empty.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using the following code to add the quotations:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data _null_;&lt;BR /&gt;file 'D:file/location/Data_Want.csv' dsd dlm=',';&lt;BR /&gt;set Data.Have ;&lt;BR /&gt;if _n_ = 1 then put &amp;nbsp;VAR1 ~ VAR2~ VAR3~ VAR4~&amp;nbsp;&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But when it's null it's showing "." instead of leaving it blank as it had prior to adding the quotations. I've searched and had no luck finding a resolution. Any suggestions would be much appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm getting this:&amp;nbsp;".",".",".","12"&lt;/P&gt;&lt;P&gt;When I need this:&amp;nbsp;&amp;nbsp;,,,"12"&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jul 2019 20:04:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-do-I-export-to-CSV-without-quotes-for-null-values/m-p/575966#M75468</guid>
      <dc:creator>datakat</dc:creator>
      <dc:date>2019-07-23T20:04:02Z</dc:date>
    </item>
    <item>
      <title>Re: How do I export to CSV without quotes for null values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-do-I-export-to-CSV-without-quotes-for-null-values/m-p/575995#M75469</link>
      <description>&lt;P&gt;The period is showing because that is the default display character for a missing value.&lt;/P&gt;
&lt;P&gt;You can get single blank by using:&lt;/P&gt;
&lt;P&gt;Options missing=" ";&lt;/P&gt;
&lt;P&gt;prior to running that code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Better would &amp;nbsp;be to use Proc Export or the data export wizard to create CSV files&amp;nbsp;but numeric values do not normally have quotes and quotes would normally only be required for character values that contain commas in delimited files.&lt;/P&gt;
&lt;P&gt;If that is not acceptable then you are likely going tto&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And why do you say "with parenthesis around the data in each field, unless it's null," but show quotes???&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jul 2019 22:27:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-do-I-export-to-CSV-without-quotes-for-null-values/m-p/575995#M75469</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-07-23T22:27:15Z</dc:date>
    </item>
    <item>
      <title>Re: How do I export to CSV without quotes for null values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-do-I-export-to-CSV-without-quotes-for-null-values/m-p/576004#M75470</link>
      <description>&lt;P&gt;I would like to export a CSV file from a SAS dataset in which the text and date variables are enclosed in quotes when there is a value present and not when the value is null.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, below, Jane does not have a middle name or a birth date, and so no "" appear around the nulls&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"First_Name","Middle_Name","Last_Name","Birth_Date"&lt;/P&gt;&lt;P&gt;"Jeff","Duke","Doe","1/1/2000"&lt;/P&gt;&lt;P&gt;"Jane",,"Doe",&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All I can manage to get in a CSV file from SAS is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"First_Name","Middle_Name","Last_Name","Birth_Date"&lt;/P&gt;&lt;P&gt;"Jeff","Duke","Doe","1/1/2000"&lt;/P&gt;&lt;P&gt;"Jane","","Doe",""&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;data _null_;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;file 'D:file/location/Data_Want.csv' dsd dlm=',';&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;set Data.Have ;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;if _n_ = 1 then '"First_Name","Middle_Name","Last_Name","Birth_Date"';&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;put &amp;nbsp;First_Name ~ Middle_Name ~ Last_Name ~ Birth_Date ~&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to do this so that the Middle_Name and Birth_Date fields will export without quotes when null? TIA&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jul 2019 23:57:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-do-I-export-to-CSV-without-quotes-for-null-values/m-p/576004#M75470</guid>
      <dc:creator>datawhisper</dc:creator>
      <dc:date>2019-07-23T23:57:02Z</dc:date>
    </item>
    <item>
      <title>Re: How do I export to CSV without quotes for null values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-do-I-export-to-CSV-without-quotes-for-null-values/m-p/576016#M75471</link>
      <description>&lt;P&gt;Have you pushed back against this (bogus) request to add the unneeded quotes around every value?&lt;/P&gt;
&lt;P&gt;What is the source of that strange requirement?&lt;/P&gt;
&lt;P&gt;Are you loading the file into some software package?&amp;nbsp; Can't the software package read a normal CSV file? What software package is it that can't read a normal CSV file?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you really have to then just generate some wallpaper code to test each variable's value for missing and use a different PUT statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  input a b $ c ;
cards;
1 red 2
. blue 3
4 . 5
;

data _null_;
  set test;
  file log dsd ;
  if missing(a) then put a @; else put a ~ @;
  if missing(b) then put b @; else put b ~ @;
  if missing(c) then put c @; else put c ~ @;
  put;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 Jul 2019 01:34:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-do-I-export-to-CSV-without-quotes-for-null-values/m-p/576016#M75471</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-07-24T01:34:53Z</dc:date>
    </item>
    <item>
      <title>Re: How do I export to CSV without quotes for null values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-do-I-export-to-CSV-without-quotes-for-null-values/m-p/576029#M75472</link>
      <description>&lt;P&gt;Thanks for the wallpaper code!&amp;nbsp; That did the trick.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jul 2019 03:28:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-do-I-export-to-CSV-without-quotes-for-null-values/m-p/576029#M75472</guid>
      <dc:creator>datakat</dc:creator>
      <dc:date>2019-07-24T03:28:55Z</dc:date>
    </item>
    <item>
      <title>Re: How do I export to CSV without quotes for null values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-do-I-export-to-CSV-without-quotes-for-null-values/m-p/576030#M75473</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/282591"&gt;@datakat&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks for the wallpaper code!&amp;nbsp; That did the trick.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;What happens if you just give them a normal CSV file without the unneeded quotes?&lt;/P&gt;
&lt;P&gt;Quotes only need to be added to values that contain the delimiter character or actual quote character.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jul 2019 03:31:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-do-I-export-to-CSV-without-quotes-for-null-values/m-p/576030#M75473</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-07-24T03:31:24Z</dc:date>
    </item>
    <item>
      <title>Re: How do I export to CSV without quotes for null values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-do-I-export-to-CSV-without-quotes-for-null-values/m-p/576033#M75474</link>
      <description>&lt;P&gt;We get errors without the quotes. Not sure why yet.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jul 2019 03:38:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-do-I-export-to-CSV-without-quotes-for-null-values/m-p/576033#M75474</guid>
      <dc:creator>datakat</dc:creator>
      <dc:date>2019-07-24T03:38:06Z</dc:date>
    </item>
    <item>
      <title>Re: How do I export to CSV without quotes for null values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-do-I-export-to-CSV-without-quotes-for-null-values/m-p/576034#M75475</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/282591"&gt;@datakat&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;We get errors without the quotes. Not sure why yet.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;What software are you using? It a known product (like R, Redshift, SPSS, SQL/Server, etc.)? Or some homemade tool?&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jul 2019 03:48:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-do-I-export-to-CSV-without-quotes-for-null-values/m-p/576034#M75475</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-07-24T03:48:37Z</dc:date>
    </item>
  </channel>
</rss>

