<?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 to save a CAS in memory table to a CSV file with quoted characters. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-save-a-CAS-in-memory-table-to-a-CSV-file-with-quoted/m-p/590045#M170915</link>
    <description>&lt;P&gt;Normal SAS considers a character variable with only spaces in it as a missing value. So I would expect that a variable that consists only of spaces would generate nothing in the CSV file as that is the normal way to represent a missing value. Perhaps CAS interprets those types of values differently?&amp;nbsp; Perhaps it supports variable length character strings?&amp;nbsp; Similarly missing numeric values should be represented by no characters in the file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a simple SAS data step to demonstrate how missing values normally appear in CSV files.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;504   data test;
505    set sashelp.class (obs=3);
506    if _n_=1 then age=.;
507    if _n_=2 then sex=' ';
508    file log dsd ;
509    put (_all_) (+0);
510   run;

Alfred,M,,69,112.5
Alice,,13,56.5,84
Barbara,F,13,65.3,98
NOTE: There were 3 observations read from the data set SASHELP.CLASS.
NOTE: The data set WORK.TEST has 3 observations and 5 variables.
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 19 Sep 2019 14:48:51 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2019-09-19T14:48:51Z</dc:date>
    <item>
      <title>How to save a CAS in memory table to a CSV file with quoted characters.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-save-a-CAS-in-memory-table-to-a-CSV-file-with-quoted/m-p/590001#M170911</link>
      <description>&lt;P&gt;I have a CAS in memory table which i want to save as a CSV file in the data source associated with the CASLIB. The tables have characters and numeric fields. I am running this code on SAS Studio in SAS Viya. Below is the code that I am using.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using PROC CASUTIL:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;proc casutil;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;save casdata="tablename" incaslib="caslib" outcaslib="caslib" casout="filename.csv" replace;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;run;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using PROC CAS:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;proc cas;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;table.save /&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;table={name="tablename" caslib="caslib"}&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;name="filename.csv" caslib="caslib" replace="yes";&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;run&lt;/FONT&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now in both the cases the result is same, i.e., the file is created as a CSV the numeric fields are coming properly without enclosing of quotes. But with the character fields, the character fields that have space in them are enclosed in quotes and the character fields without any space in them are not enclosed in quotes. Some thing like shown below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;acct_num,org,cust_num,int_status,curr_bal,block_code&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;0004010391500712881,400,0004010391500646024,A,5000,F&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;0004010391500712882,400,0004010391500712883,D,700.5,L&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;0004010391500712883,400,0004010391500712883,D,0,L&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;0004010391500712884,400,0004010391500712883,D,1000,""&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;0004010391500712885,400,0004010391500712883,D,1000,abcd&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;0004010391500712886,400,0004010391500712883,"",1000,abcd&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;0004010391500712887,400,0004010391500712883,"",1000,abcd&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Wherein the columns int_status and block_code are character fields.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This seems like a very inconsistent behavior, or may be I am unaware of the reason.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My requirement is that the character fields should be enclosed in double quotes or at the very least none of the characters fields are enclosed in quotes. I want to achieve uniformity in how a specific type of data is written. My preference is that the characters fields should be enclosed in double quotes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there is some option using which this can be achieved?&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2019 12:35:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-save-a-CAS-in-memory-table-to-a-CSV-file-with-quoted/m-p/590001#M170911</guid>
      <dc:creator>rahulrai</dc:creator>
      <dc:date>2019-09-19T12:35:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to save a CAS in memory table to a CSV file with quoted characters.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-save-a-CAS-in-memory-table-to-a-CSV-file-with-quoted/m-p/590005#M170912</link>
      <description>&lt;P&gt;Looks like a normal CSV file, other than those places with two double quote characters next to each other.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Only values that contain the delimiter character or the quote character need to have quotes around them. Whether you think they represent numbers or strings doesn't matter in whether the quotes are needed or not.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2019 12:58:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-save-a-CAS-in-memory-table-to-a-CSV-file-with-quoted/m-p/590005#M170912</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-09-19T12:58:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to save a CAS in memory table to a CSV file with quoted characters.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-save-a-CAS-in-memory-table-to-a-CSV-file-with-quoted/m-p/590007#M170913</link>
      <description>&lt;P&gt;That is normal and you can't change it.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2019 13:05:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-save-a-CAS-in-memory-table-to-a-CSV-file-with-quoted/m-p/590007#M170913</guid>
      <dc:creator>alexal</dc:creator>
      <dc:date>2019-09-19T13:05:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to save a CAS in memory table to a CSV file with quoted characters.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-save-a-CAS-in-memory-table-to-a-CSV-file-with-quoted/m-p/590034#M170914</link>
      <description>&lt;P&gt;Hi Tom,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the inputs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The Double Quotes next to each other are "spaces" in my table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now when you say&amp;nbsp;&lt;EM&gt;"&lt;SPAN&gt;Only values that contain the delimiter character or the quote character need to have quotes around&lt;/SPAN&gt;&lt;/EM&gt; &lt;EM&gt;them"&amp;nbsp;&lt;/EM&gt;, do you mean that it takes "space" as a delimiter? Because my string does not have quotes and the delimiter for my file is "comma".&lt;/P&gt;&lt;P&gt;and if it considers space as a delimiter can you suggest any option which specifies that space is not a delimiter?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2019 14:18:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-save-a-CAS-in-memory-table-to-a-CSV-file-with-quoted/m-p/590034#M170914</guid>
      <dc:creator>rahulrai</dc:creator>
      <dc:date>2019-09-19T14:18:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to save a CAS in memory table to a CSV file with quoted characters.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-save-a-CAS-in-memory-table-to-a-CSV-file-with-quoted/m-p/590045#M170915</link>
      <description>&lt;P&gt;Normal SAS considers a character variable with only spaces in it as a missing value. So I would expect that a variable that consists only of spaces would generate nothing in the CSV file as that is the normal way to represent a missing value. Perhaps CAS interprets those types of values differently?&amp;nbsp; Perhaps it supports variable length character strings?&amp;nbsp; Similarly missing numeric values should be represented by no characters in the file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a simple SAS data step to demonstrate how missing values normally appear in CSV files.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;504   data test;
505    set sashelp.class (obs=3);
506    if _n_=1 then age=.;
507    if _n_=2 then sex=' ';
508    file log dsd ;
509    put (_all_) (+0);
510   run;

Alfred,M,,69,112.5
Alice,,13,56.5,84
Barbara,F,13,65.3,98
NOTE: There were 3 observations read from the data set SASHELP.CLASS.
NOTE: The data set WORK.TEST has 3 observations and 5 variables.
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2019 14:48:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-save-a-CAS-in-memory-table-to-a-CSV-file-with-quoted/m-p/590045#M170915</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-09-19T14:48:51Z</dc:date>
    </item>
  </channel>
</rss>

