<?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: Does SAS have a capability to automatically add Quotes to output values based on datatype in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Does-SAS-have-a-capability-to-automatically-add-Quotes-to-output/m-p/902167#M356499</link>
    <description>&lt;P&gt;What is wrong with QUOTE? Please provide details.&lt;/P&gt;</description>
    <pubDate>Wed, 08 Nov 2023 19:56:37 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2023-11-08T19:56:37Z</dc:date>
    <item>
      <title>Does SAS have a capability to automatically add Quotes to output values based on datatype</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Does-SAS-have-a-capability-to-automatically-add-Quotes-to-output/m-p/902129#M356484</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;I was wondering if SAS has a capability to automatically add Quotes or Double quotes to output fields values based on say if the field is of Character or Numeric or Packed decimal value&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Say if the field is CHAR&lt;/P&gt;&lt;P&gt;Name&lt;/P&gt;&lt;P&gt;Ivy&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am expecting the output in the file as below&lt;/P&gt;&lt;P&gt;"Ivy"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the field values are not CHAR then it should not add the double quotes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Ramanujam&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2023 18:31:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Does-SAS-have-a-capability-to-automatically-add-Quotes-to-output/m-p/902129#M356484</guid>
      <dc:creator>ramkal21</dc:creator>
      <dc:date>2023-11-08T18:31:18Z</dc:date>
    </item>
    <item>
      <title>Re: Does SAS have a capability to automatically add Quotes to output values based on datatype</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Does-SAS-have-a-capability-to-automatically-add-Quotes-to-output/m-p/902138#M356485</link>
      <description>&lt;P&gt;Let the QUOTE function do all the work.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmmvacdc/9.4/lefunctionsref/p059exu866hqw2n0zw9aoxf3p6oj.htm" target="_blank" rel="noopener"&gt;https://documentation.sas.com/doc/en/pgmmvacdc/9.4/lefunctionsref/p059exu866hqw2n0zw9aoxf3p6oj.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Which brings up the question ... why would this be helpful? Why do you need text inside double or single quotes?&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2023 18:54:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Does-SAS-have-a-capability-to-automatically-add-Quotes-to-output/m-p/902138#M356485</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-11-08T18:54:43Z</dc:date>
    </item>
    <item>
      <title>Re: Does SAS have a capability to automatically add Quotes to output values based on datatype</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Does-SAS-have-a-capability-to-automatically-add-Quotes-to-output/m-p/902142#M356487</link>
      <description>Define automatically? What do you mean by output? SAS really only has numeric/character.</description>
      <pubDate>Wed, 08 Nov 2023 18:48:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Does-SAS-have-a-capability-to-automatically-add-Quotes-to-output/m-p/902142#M356487</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-11-08T18:48:21Z</dc:date>
    </item>
    <item>
      <title>Re: Does SAS have a capability to automatically add Quotes to output values based on datatype</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Does-SAS-have-a-capability-to-automatically-add-Quotes-to-output/m-p/902159#M356496</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp; for your quick response. I am trying to mimic output from a vendor product utility (which is being replaced) and that utility automatically identifies fields datatypes based on it's values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Other than QUOTE, could you let me know if there is any other option?&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2023 19:34:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Does-SAS-have-a-capability-to-automatically-add-Quotes-to-output/m-p/902159#M356496</guid>
      <dc:creator>ramkal21</dc:creator>
      <dc:date>2023-11-08T19:34:57Z</dc:date>
    </item>
    <item>
      <title>Re: Does SAS have a capability to automatically add Quotes to output values based on datatype</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Does-SAS-have-a-capability-to-automatically-add-Quotes-to-output/m-p/902167#M356499</link>
      <description>&lt;P&gt;What is wrong with QUOTE? Please provide details.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2023 19:56:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Does-SAS-have-a-capability-to-automatically-add-Quotes-to-output/m-p/902167#M356499</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-11-08T19:56:37Z</dc:date>
    </item>
    <item>
      <title>Re: Does SAS have a capability to automatically add Quotes to output values based on datatype</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Does-SAS-have-a-capability-to-automatically-add-Quotes-to-output/m-p/902173#M356504</link>
      <description>You can easily customize the output format of a variable, even automate it dynamically. However, you'll need to show an example of what you're trying to achieve if you want any examples otherwise, a vague question (is something possible) gets a vague answer(yes, it's possible).</description>
      <pubDate>Wed, 08 Nov 2023 20:07:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Does-SAS-have-a-capability-to-automatically-add-Quotes-to-output/m-p/902173#M356504</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-11-08T20:07:47Z</dc:date>
    </item>
    <item>
      <title>Re: Does SAS have a capability to automatically add Quotes to output values based on datatype</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Does-SAS-have-a-capability-to-automatically-add-Quotes-to-output/m-p/902191#M356509</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;.&amp;nbsp; I was able to get my need satisfied by using $QUOTE format (please see below link)., basically was trying to reduce lines of code. Using $QUOTE format eliminated the need to have a separate line for QUOTE function.&amp;nbsp; &amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/vdmmlcdc/8.1/ds2ref/p180g91lfrpgfnn0zw28u8hwu3mt.htm#:~:text=Writes%20data%20values%20that%20are%20enclosed%20in%20double%20quotation%20marks" target="_blank"&gt;https://documentation.sas.com/doc/en/vdmmlcdc/8.1/ds2ref/p180g91lfrpgfnn0zw28u8hwu3mt.htm#:~:text=Writes%20data%20values%20that%20are%20enclosed%20in%20double%20quotation%20marks&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;var1 = QUOTE(var2);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;replaced it as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;put var1 $quote8.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My output is a comma delimited file and using 'Quotes' for characters eliminates the confusion when the file is imported at the receiving end.&lt;/P&gt;&lt;P&gt;Hope this clarifies.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you both again for leading me to the right solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ramanujam&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2023 21:06:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Does-SAS-have-a-capability-to-automatically-add-Quotes-to-output/m-p/902191#M356509</guid>
      <dc:creator>ramkal21</dc:creator>
      <dc:date>2023-11-08T21:06:06Z</dc:date>
    </item>
    <item>
      <title>Re: Does SAS have a capability to automatically add Quotes to output values based on datatype</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Does-SAS-have-a-capability-to-automatically-add-Quotes-to-output/m-p/902196#M356512</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;format _character_ $quote.;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Nov 2023 21:23:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Does-SAS-have-a-capability-to-automatically-add-Quotes-to-output/m-p/902196#M356512</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-11-08T21:23:14Z</dc:date>
    </item>
    <item>
      <title>Re: Does SAS have a capability to automatically add Quotes to output values based on datatype</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Does-SAS-have-a-capability-to-automatically-add-Quotes-to-output/m-p/902204#M356515</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/459907"&gt;@ramkal21&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp; for your quick response. I am trying to mimic output from a vendor product utility (which is being replaced) and that utility automatically identifies fields datatypes based on it's values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Other than QUOTE, could you let me know if there is any other option?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I assume you mean that what ever process is READING the files produced by the thing being replaced is currently GUESSING that quoted values should be character variables?&amp;nbsp; Having a system that depends on guessing is not really a good idea.&amp;nbsp; Can you fix the receiver side also to accept a sperate file with the variable definitions?&amp;nbsp; Then you could just write a normal CSV file were quotes are only added when the are NEEDED.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are writing a CSV file then you probably want to use the ~ format modifier in the PUT statement and not the QUOTE() function of $QUOTE format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  file OUT dsd ;
  set sashelp.class ;
  put name ~ sex ~ age height weight;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;"Alfred","M",14,69,112.5
"Alice","F",13,56.5,84
"Barbara","F",13,65.3,98
"Carol","F",14,62.8,102.5
"Henry","M",14,63.5,102.5
"James","M",12,57.3,83
"Jane","F",12,59.8,84.5
"Janet","F",15,62.5,112.5
"Jeffrey","M",13,62.5,84
"John","M",12,59,99.5
"Joyce","F",11,51.3,50.5
"Judy","F",14,64.3,90
"Louise","F",12,56.3,77
"Mary","F",15,66.5,112
"Philip","M",16,72,150
"Robert","M",12,64.8,128
"Ronald","M",15,67,133
"Thomas","M",11,57.5,85
"William","M",15,66.5,112
&lt;/PRE&gt;
&lt;P&gt;You could do a little work to help generate that automatically if you want.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
select catx(' ',nliteral(name),case when type='char' then '~' else ' ' end)
  into :varlist separated by ' '
  from dictionary.columns
  where libname='SASHELP' and memname='CLASS'
  order by varnum
;
quit;

data _null_;
  file log dsd ;
  set sashelp.class;
  put &amp;amp;varlist;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You could also try using ODS CSV as it has the nasty habit of adding extra quotes like that.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename out temp;
ods csv file=out;
proc print data=sashelp.class noobs; run;
ods csv close;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result&lt;/P&gt;
&lt;PRE&gt;"Name","Sex","Age","Height","Weight"
"Alfred","M",14,69.0,112.5
"Alice","F",13,56.5,84.0
"Barbara","F",13,65.3,98.0
"Carol","F",14,62.8,102.5
"Henry","M",14,63.5,102.5
"James","M",12,57.3,83.0
"Jane","F",12,59.8,84.5
"Janet","F",15,62.5,112.5
"Jeffrey","M",13,62.5,84.0
"John","M",12,59.0,99.5
"Joyce","F",11,51.3,50.5
"Judy","F",14,64.3,90.0
"Louise","F",12,56.3,77.0
"Mary","F",15,66.5,112.0
"Philip","M",16,72.0,150.0
"Robert","M",12,64.8,128.0
"Ronald","M",15,67.0,133.0
"Thomas","M",11,57.5,85.0
"William","M",15,66.5,112.0
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2023 22:00:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Does-SAS-have-a-capability-to-automatically-add-Quotes-to-output/m-p/902204#M356515</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-11-08T22:00:06Z</dc:date>
    </item>
    <item>
      <title>Re: Does SAS have a capability to automatically add Quotes to output values based on datatype</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Does-SAS-have-a-capability-to-automatically-add-Quotes-to-output/m-p/902249#M356537</link>
      <description>&lt;P&gt;Should this quoting be based on variable data type of which SAS 9.n only got CHAR and NUM or based on actual values meaning for the same variable there could be cases with and without quotes based on the actual string?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need to share more detail as well as some representative sample data (please provided via a tested SAS datastep with datalines) and desired result based on the sample data.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2023 03:50:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Does-SAS-have-a-capability-to-automatically-add-Quotes-to-output/m-p/902249#M356537</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-11-09T03:50:01Z</dc:date>
    </item>
  </channel>
</rss>

