<?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 output apostrophe correctly in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-output-apostrophe-correctly/m-p/544708#M16745</link>
    <description>&lt;P&gt;It may be a data content issue where the character you are seeing is not a simple apostrophe.&lt;/P&gt;
&lt;P&gt;When I run this code:&lt;/P&gt;
&lt;PRE&gt;data have;
   x="Value with an ' in the middle";
run;

proc export data=have
   outfile ="x:\data\test.xlsx"
   dbms=xlsx replace;
   sheet ='Have';
run;&lt;/PRE&gt;
&lt;P&gt;The result I see in Excel is&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;TABLE width="210"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="210"&gt;Value with an ' in the middle&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might have a Unicode character or similar that is getting mapped that way. Does the value appear as a straight up and down apostrophe in the SAS dataset, like this: &lt;FONT size="5"&gt;&lt;STRONG&gt;'&lt;/STRONG&gt;&lt;/FONT&gt; &amp;nbsp;or the source file or does it have a curl like this: &lt;FONT size="5"&gt;&lt;STRONG&gt;’&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;The curly character is a different character than a simple apostrophe.&lt;/P&gt;</description>
    <pubDate>Wed, 20 Mar 2019 21:20:24 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2019-03-20T21:20:24Z</dc:date>
    <item>
      <title>How to output apostrophe correctly</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-output-apostrophe-correctly/m-p/544596#M16741</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have&amp;nbsp;imported a data set from excel(.xlsx) to SAS and have to output part of the data back to excel again. I found that the apostrophe (')&amp;nbsp;will be translated to &amp;amp;apos; in excel(.xlsx). Any recommendations on the issue?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;
&lt;P&gt;Ying&lt;/P&gt;</description>
      <pubDate>Wed, 20 Mar 2019 14:58:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-output-apostrophe-correctly/m-p/544596#M16741</guid>
      <dc:creator>CynthiaFan</dc:creator>
      <dc:date>2019-03-20T14:58:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to output apostrophe correctly</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-output-apostrophe-correctly/m-p/544618#M16742</link>
      <description>&lt;P&gt;Please show the code you are using to create the Excel output.&lt;/P&gt;
&lt;P&gt;That example makes me suspect you are actually creating HTML and not Excel output.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Mar 2019 15:51:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-output-apostrophe-correctly/m-p/544618#M16742</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-03-20T15:51:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to output apostrophe correctly</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-output-apostrophe-correctly/m-p/544634#M16743</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your early response. Here's my code to export to excel. Let me know where to add or delete&amp;nbsp;code to&amp;nbsp;leave apostrophe as is.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/*export*/&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;export&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;data&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=x2017_dd&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;outfile&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"e:\MDO\Surveillance\NXS\CTC_2017_.xlsx"&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;dbms&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=xlsx &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;replace&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;sheet&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"x2017"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ying&lt;/P&gt;</description>
      <pubDate>Wed, 20 Mar 2019 16:21:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-output-apostrophe-correctly/m-p/544634#M16743</guid>
      <dc:creator>CynthiaFan</dc:creator>
      <dc:date>2019-03-20T16:21:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to output apostrophe correctly</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-output-apostrophe-correctly/m-p/544708#M16745</link>
      <description>&lt;P&gt;It may be a data content issue where the character you are seeing is not a simple apostrophe.&lt;/P&gt;
&lt;P&gt;When I run this code:&lt;/P&gt;
&lt;PRE&gt;data have;
   x="Value with an ' in the middle";
run;

proc export data=have
   outfile ="x:\data\test.xlsx"
   dbms=xlsx replace;
   sheet ='Have';
run;&lt;/PRE&gt;
&lt;P&gt;The result I see in Excel is&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;TABLE width="210"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="210"&gt;Value with an ' in the middle&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might have a Unicode character or similar that is getting mapped that way. Does the value appear as a straight up and down apostrophe in the SAS dataset, like this: &lt;FONT size="5"&gt;&lt;STRONG&gt;'&lt;/STRONG&gt;&lt;/FONT&gt; &amp;nbsp;or the source file or does it have a curl like this: &lt;FONT size="5"&gt;&lt;STRONG&gt;’&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;The curly character is a different character than a simple apostrophe.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Mar 2019 21:20:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-output-apostrophe-correctly/m-p/544708#M16745</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-03-20T21:20:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to output apostrophe correctly</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-output-apostrophe-correctly/m-p/544742#M16748</link>
      <description>&lt;P&gt;&lt;FONT size="3"&gt;Hi,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="3"&gt;I just copy and paste the sign from original Excel file:&lt;/FONT&gt;&lt;FONT size="7"&gt;'&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="3"&gt;I checked the original excel file, format for that problematic variable is 'general'. When&amp;nbsp;read in&amp;nbsp;to SAS EG,&amp;nbsp;&amp;nbsp;it's read as character. I may need to change the variable's format to&amp;nbsp;txt&amp;nbsp;in original&amp;nbsp;Excel file.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="3"&gt;Thank you.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="3"&gt;Ying&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2019 00:25:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-output-apostrophe-correctly/m-p/544742#M16748</guid>
      <dc:creator>CynthiaFan</dc:creator>
      <dc:date>2019-03-21T00:25:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to output apostrophe correctly</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-output-apostrophe-correctly/m-p/544764#M16749</link>
      <description>&lt;P&gt;Another option is you can run this little SAS program, with your problem character in place of the single quote.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
ProblemChar = "'";
ProblemCharHex = put(ProblemChar, $hex2.);
putlog ProblemCharHex=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I run it with a single quote, the log says&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ProblemCharHex=27&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2019 02:20:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-output-apostrophe-correctly/m-p/544764#M16749</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2019-03-21T02:20:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to output apostrophe correctly</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-output-apostrophe-correctly/m-p/544902#M16751</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for all the solutions. Then it happens that when the original Excel file (xlsx created back in 2017) was opened and saved again without any changes&amp;nbsp;then&amp;nbsp;the apostrophe can be read in to SAS correctly. Not sure if&amp;nbsp;to open and save all of those excel files since there's a lot of bunches of them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ying&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2019 15:32:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-output-apostrophe-correctly/m-p/544902#M16751</guid>
      <dc:creator>CynthiaFan</dc:creator>
      <dc:date>2019-03-21T15:32:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to output apostrophe correctly</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-output-apostrophe-correctly/m-p/544913#M16752</link>
      <description>&lt;P&gt;If you can identify the character, such as copy and paste in a SAS data set you should be able to use the TRANSLATE function to fix them. The code below uses an * to represent the offending character as seen in SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data example;
   x='some string with * that I * want to change * to apostrophe';
   y='another string with * to fix';
   array ___z _character_;
   do _i_ = 1 to dim(___z);
     ___z[_i_] = translate(___z[_i_],"'","*");
   end;
run; &lt;/PRE&gt;
&lt;P&gt;The semi-obnoxious array name is just to use something unlikely to be in an existing data set to avoid accidentally using an array with the same name as a variable. Something unlikely to appear allows better automation of code to process a bunch of data sets.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2019 15:55:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-output-apostrophe-correctly/m-p/544913#M16752</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-03-21T15:55:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to output apostrophe correctly</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-output-apostrophe-correctly/m-p/544932#M16754</link>
      <description>&lt;P&gt;Be careful about using TRANSLATE. You may be in the realm of multi-byte character sets / unicode, and may need to use KTRANSLATE and the other K functions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I fell into this snake pit a few months ago on a project; yuck!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tom&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2019 16:30:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-output-apostrophe-correctly/m-p/544932#M16754</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2019-03-21T16:30:26Z</dc:date>
    </item>
  </channel>
</rss>

