<?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 How to read in a variable contains &amp;quot;±&amp;quot; into sas in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-in-a-variable-contains-quot-quot-into-sas/m-p/886143#M350172</link>
    <description>&lt;P&gt;Hi all :&lt;/P&gt;
&lt;P&gt;There is a one variable got "±" and I tried using these code, it doesn't work.&lt;/P&gt;
&lt;P&gt;------------------------------------&lt;/P&gt;
&lt;P&gt;Variable X had multiple records:&lt;/P&gt;
&lt;P&gt;a fox is running&lt;/P&gt;
&lt;P&gt;a cat has&amp;nbsp;&lt;STRONG&gt;±1 years&lt;/STRONG&gt; to live&lt;/P&gt;
&lt;P&gt;an apple&amp;nbsp;&lt;/P&gt;
&lt;P&gt;------------------------------&lt;/P&gt;
&lt;P&gt;thank you,&lt;/P&gt;
&lt;P&gt;purple&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*Get a list of SAS byte for special character*/
data _null_;
do k=1 to 255;
x=byte(k);
put k +10 x;
end;
run;

data need;
set have;
 _a=tranwrd(a,byte(177),'Plus or Minus');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;the log&amp;nbsp;&lt;BR /&gt;ERROR: Some character data was lost during transcoding in the&lt;BR /&gt;dataset have. Either the data contains characters that&lt;BR /&gt;are not representable in the new encoding or truncation&lt;BR /&gt;occurred during transcoding.&lt;/P&gt;</description>
    <pubDate>Mon, 24 Jul 2023 19:47:53 GMT</pubDate>
    <dc:creator>purpleclothlady</dc:creator>
    <dc:date>2023-07-24T19:47:53Z</dc:date>
    <item>
      <title>How to read in a variable contains "±" into sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-in-a-variable-contains-quot-quot-into-sas/m-p/886143#M350172</link>
      <description>&lt;P&gt;Hi all :&lt;/P&gt;
&lt;P&gt;There is a one variable got "±" and I tried using these code, it doesn't work.&lt;/P&gt;
&lt;P&gt;------------------------------------&lt;/P&gt;
&lt;P&gt;Variable X had multiple records:&lt;/P&gt;
&lt;P&gt;a fox is running&lt;/P&gt;
&lt;P&gt;a cat has&amp;nbsp;&lt;STRONG&gt;±1 years&lt;/STRONG&gt; to live&lt;/P&gt;
&lt;P&gt;an apple&amp;nbsp;&lt;/P&gt;
&lt;P&gt;------------------------------&lt;/P&gt;
&lt;P&gt;thank you,&lt;/P&gt;
&lt;P&gt;purple&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*Get a list of SAS byte for special character*/
data _null_;
do k=1 to 255;
x=byte(k);
put k +10 x;
end;
run;

data need;
set have;
 _a=tranwrd(a,byte(177),'Plus or Minus');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;the log&amp;nbsp;&lt;BR /&gt;ERROR: Some character data was lost during transcoding in the&lt;BR /&gt;dataset have. Either the data contains characters that&lt;BR /&gt;are not representable in the new encoding or truncation&lt;BR /&gt;occurred during transcoding.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jul 2023 19:47:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-in-a-variable-contains-quot-quot-into-sas/m-p/886143#M350172</guid>
      <dc:creator>purpleclothlady</dc:creator>
      <dc:date>2023-07-24T19:47:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to read in a variable contains "±" into sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-in-a-variable-contains-quot-quot-into-sas/m-p/886163#M350181</link>
      <description>&lt;P&gt;As your message indicates what bytes to store into your variable to make it print a particular glyph depends on what ENCODING you are using.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Normal ASCII codes only cover the characters between a space ('20'x or 32 decimal) and a tilda ('7E'x or 126 decimal).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In general it would be much easier and reproducible to just store the two character string '+-' or perhaps the three character string '+/-' into the variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is a UNICODE character for that, so if your SAS session is using UTF-8 as the encoding you could store it.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://en.wikipedia.org/wiki/Plus%E2%80%93minus_sign" target="_blank"&gt;https://en.wikipedia.org/wiki/Plus%E2%80%93minus_sign&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It should be available in LATIN1 or WLATIN1 encoding also.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://en.wikipedia.org/wiki/Western_Latin_character_sets_(computing)" target="_blank"&gt;https://en.wikipedia.org/wiki/Western_Latin_character_sets_(computing)&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;6    data test;
7      length latin1 $1 utf8 $2;
8      latin1='B1'x;
9      utf8=kcvt(latin1,'latin1','utf-8');
10     put (_all_) (=:$hex./);
11   run;

latin1=B1
utf8=C2B1
&lt;/PRE&gt;</description>
      <pubDate>Mon, 24 Jul 2023 20:57:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-in-a-variable-contains-quot-quot-into-sas/m-p/886163#M350181</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-07-24T20:57:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to read in a variable contains "±" into sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-in-a-variable-contains-quot-quot-into-sas/m-p/886164#M350182</link>
      <description>&lt;P&gt;As your message indicates what bytes to store into your variable to make it print a particular glyph depends on what ENCODING you are using.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Normal ASCII codes only cover the characters between a space ('20'x or 32 decimal) and a tilda ('7E'x or 126 decimal).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In general it would be much easier and reproducible to just store the two character string '+-' or perhaps the three character string '+/-' into the variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is a UNICODE character for that, so if your SAS session is using UTF-8 as the encoding you could store it.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://en.wikipedia.org/wiki/Plus%E2%80%93minus_sign" target="_blank"&gt;https://en.wikipedia.org/wiki/Plus%E2%80%93minus_sign&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It should be available in LATIN1 or WLATIN1 encoding also.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://en.wikipedia.org/wiki/Western_Latin_character_sets_(computing)" target="_blank"&gt;https://en.wikipedia.org/wiki/Western_Latin_character_sets_(computing)&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;6    data test;
7      length latin1 $1 utf8 $2;
8      latin1='B1'x;
9      utf8=kcvt(latin1,'latin1','utf-8');
10     put (_all_) (=:$hex./);
11   run;

latin1=B1
utf8=C2B1
&lt;/PRE&gt;</description>
      <pubDate>Mon, 24 Jul 2023 20:59:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-in-a-variable-contains-quot-quot-into-sas/m-p/886164#M350182</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-07-24T20:59:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to read in a variable contains "±" into sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-in-a-variable-contains-quot-quot-into-sas/m-p/886165#M350183</link>
      <description>&lt;P&gt;I'm surprised you get the error that you show us with the code that you show us. Seems impossible.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;No HAVE data set is created. No variable named A is created. Please, from now on, show us the EXACT code you are running, and not some close approximation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This works:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
do k=1 to 255;
x=byte(k);
put k +10 x;
end;
run;

data need;
set have;
 _a=tranwrd(x,byte(177),'Plus or Minus');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jul 2023 21:04:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-in-a-variable-contains-quot-quot-into-sas/m-p/886165#M350183</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-07-24T21:04:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to read in a variable contains "±" into sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-in-a-variable-contains-quot-quot-into-sas/m-p/886257#M350218</link>
      <description>&lt;P&gt;HI Tom:&lt;/P&gt;
&lt;P&gt;thank you for helping.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am using SAS V9.4 M7, and I don't know which ENCODING i am using.&lt;/P&gt;
&lt;P&gt;How may I know that?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If we know which encoding should be used, can u just use this code (with the correct ENCODING) to read in SAS dataset&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;thanks again.&lt;/P&gt;
&lt;P&gt;Purple&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jul 2023 15:25:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-in-a-variable-contains-quot-quot-into-sas/m-p/886257#M350218</guid>
      <dc:creator>purpleclothlady</dc:creator>
      <dc:date>2023-07-25T15:25:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to read in a variable contains "±" into sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-in-a-variable-contains-quot-quot-into-sas/m-p/886261#M350220</link>
      <description>&lt;P&gt;Check the system encoding of your current SAS session.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%put %sysfunc(getoption(encoding));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you are reading from a SAS dataset then check the encoding of the dataset using PROC CONTENTS.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc contents data=mylib.mydataset ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;How did you start SAS?&lt;/P&gt;
&lt;P&gt;Did you type a command at the command line?&amp;nbsp; Do you have a separated command or an option on the command you are using to pick the session encoding?&lt;BR /&gt;Did you click on some Windows ICON?&amp;nbsp; Which one?&amp;nbsp; On Windows you should normally have a option to launch SAS with Unicode support.&lt;/P&gt;
&lt;P&gt;Are you using from front-end tool to submit your SAS code?&amp;nbsp; Such as Enterprise Guide or SAS/Studio?&amp;nbsp; If so then make sure you connect to an SAS application server that is using UTF-8 encoding.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jul 2023 15:51:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-in-a-variable-contains-quot-quot-into-sas/m-p/886261#M350220</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-07-25T15:51:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to read in a variable contains "±" into sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-in-a-variable-contains-quot-quot-into-sas/m-p/886263#M350221</link>
      <description>&lt;P&gt;hi Tom:&lt;/P&gt;
&lt;P&gt;here is using the PROC CONTENTS-- UTF-8 Unicode(UTF-8)&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="purpleclothlady_0-1690301581638.png" style="width: 752px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/86083iDA1CF69D0D12B251/image-dimensions/752x126?v=v2" width="752" height="126" role="button" title="purpleclothlady_0-1690301581638.png" alt="purpleclothlady_0-1690301581638.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;if that is the case, I should use UTF&amp;nbsp;&lt;/P&gt;
&lt;TABLE&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;UTF-8 Encoding:&lt;/TD&gt;
&lt;TD&gt;&lt;STRONG&gt;0xC2 0xB1&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;to read in SAS dataset, is this correct?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;thanks again&lt;/P&gt;
&lt;P&gt;purple&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jul 2023 16:23:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-in-a-variable-contains-quot-quot-into-sas/m-p/886263#M350221</guid>
      <dc:creator>purpleclothlady</dc:creator>
      <dc:date>2023-07-25T16:23:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to read in a variable contains "±" into sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-in-a-variable-contains-quot-quot-into-sas/m-p/886270#M350224</link>
      <description>&lt;P&gt;&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/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;:&lt;/P&gt;
&lt;P&gt;thanks for helping. it works but didn't give the result I need.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="purpleclothlady_0-1690304797982.png" style="width: 549px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/86085iB3B50190852C51D5/image-dimensions/549x247?v=v2" width="549" height="247" role="button" title="purpleclothlady_0-1690304797982.png" alt="purpleclothlady_0-1690304797982.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried to search and tried this code, still got log error message.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;data test (encoding=UTF8);&lt;BR /&gt;set myfile.test;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jul 2023 17:09:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-in-a-variable-contains-quot-quot-into-sas/m-p/886270#M350224</guid>
      <dc:creator>purpleclothlady</dc:creator>
      <dc:date>2023-07-25T17:09:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to read in a variable contains "±" into sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-in-a-variable-contains-quot-quot-into-sas/m-p/886273#M350226</link>
      <description>&lt;P&gt;You seem to have attached pictures from the SAS Display Manager user interface.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To see if the character is working properly please print it to an ODS destination, like an HTML output and look at it there.&amp;nbsp; SAS has not updated Display Manager to really support extended characters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You also need to check what encoding your SAS session is using.&amp;nbsp; If it is use LATIN1 or WLATIN1 then you should see the 'C2B1'x character string in the SAS datasets transcoded into the 'B1'x character string while SAS is using the data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To see what characters are there print the values with the $HEX format so that each character is printed used two hexadecimal digits.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jul 2023 17:30:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-in-a-variable-contains-quot-quot-into-sas/m-p/886273#M350226</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-07-25T17:30:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to read in a variable contains "±" into sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-in-a-variable-contains-quot-quot-into-sas/m-p/886386#M350256</link>
      <description>&lt;P&gt;If the problem occurs when you are using the ± symbol, why are you showing us the data set for other characters????&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jul 2023 10:09:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-in-a-variable-contains-quot-quot-into-sas/m-p/886386#M350256</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-07-26T10:09:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to read in a variable contains "±" into sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-in-a-variable-contains-quot-quot-into-sas/m-p/886476#M350283</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;:&lt;/P&gt;
&lt;P&gt;Thank you again for your support, this is really a great place to ask for SAS help.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;purple&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*------------------------Migrating Data from WLATIN1 to UTF-8------------------------------------
                                   REFERENCE:
 https://documentation.sas.com/doc/en/pgmsascdc/v_006/viyadatamig/p1eedruqfsgqqcn1pmjof4br5xvt.htm
/*------------------------------------------------------------------------------------------------*/
/*===Step1: Find out WHICH Encoding is on Your SAS session
    - Mine is: SAS V9.4===*/
proc options option=encoding;
run;

/*====Step2: Use ENCODING= option to transform WLATIN1 TO UTF-8 ===*/
 data need; 
 set have (encoding=wlatin1);
 _newVar=pahdx;

  if index(compress(_newvar),"1year")&amp;gt;0;
	/*Recode ±*/
	_new=tranwrd(_newvar,"â‰¥", "±");
 keep pahdx _new:;
 run;

proc print data=need;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;proc print output screen shot from SAS window -Result:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="purpleclothlady_0-1690389438949.png" style="width: 661px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/86135iA01EA16B9BA27340/image-dimensions/661x179?v=v2" width="661" height="179" role="button" title="purpleclothlady_0-1690389438949.png" alt="purpleclothlady_0-1690389438949.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jul 2023 16:38:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-in-a-variable-contains-quot-quot-into-sas/m-p/886476#M350283</guid>
      <dc:creator>purpleclothlady</dc:creator>
      <dc:date>2023-07-26T16:38:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to read in a variable contains "±" into sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-in-a-variable-contains-quot-quot-into-sas/m-p/886503#M350294</link>
      <description>&lt;P&gt;Do not put literal non-7bit ASCII characters into your CODE.&amp;nbsp; That is just asking for problems.&lt;/P&gt;
&lt;P&gt;Use the hex code literals instead.&lt;/P&gt;
&lt;P&gt;'B1'x should be the code for that plus minus character.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your actual file has 3 bytes for the plus minus then perhaps it is not really UTF-8?&amp;nbsp; Or perhaps the creator of the dataset had already had their own troubles with encoding.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jul 2023 17:56:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-in-a-variable-contains-quot-quot-into-sas/m-p/886503#M350294</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-07-26T17:56:35Z</dc:date>
    </item>
    <item>
      <title>Question-  How to read in a variable contains "±" into sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-in-a-variable-contains-quot-quot-into-sas/m-p/886507#M350297</link>
      <description>&lt;P&gt;hi Tom:&lt;/P&gt;
&lt;P&gt;The data came from 3rd party -Medidata. so I don't know what happended to the entry.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;I don't understand what does this mean-&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;"Do not put literal non-7bit ASCII characters into your CODE.&amp;nbsp; That is just asking for problems.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;Use the hex code literals instead.&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color="#0000FF"&gt;'B1'x should be the code for that plus minus character.&lt;/FONT&gt;"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Do I need to code like this in SAS window 10 enhanced editor?&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;thank you ,&lt;/P&gt;
&lt;P&gt;Purple&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; data need; 
 set cldata.mh(encoding=wlatin1);
 _newVar=pahdx;

  if index(compress(_newvar),"1year")&amp;gt;0;

	/*Recode ±*/
	/*_new=tranwrd(_newvar,"â‰¥", "±");*/
    /*???hexcode???- Is this part you are talking about*/	
      _new=tranwrd(_newvar,"B1x", "±");
      keep pahdx _new:;
 run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jul 2023 18:17:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-in-a-variable-contains-quot-quot-into-sas/m-p/886507#M350297</guid>
      <dc:creator>purpleclothlady</dc:creator>
      <dc:date>2023-07-26T18:17:52Z</dc:date>
    </item>
    <item>
      <title>Re: Question-  How to read in a variable contains "±" into sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-in-a-variable-contains-quot-quot-into-sas/m-p/886563#M350318</link>
      <description>&lt;P&gt;No.&lt;/P&gt;
&lt;P&gt;Instead of typing/copying the characters into your code replace it with CODE that will create the character.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So instead of typing&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;'±'
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;use&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; 'B1'x&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;They will both create the same thing&amp;nbsp; when you are using LATIN1 encoding.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But if you ran the first one in a SAS session using UTF-8 encoding you would instead get the two byte string 'C2B1'x instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So instead of&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;new=tranwrd(_newvar,"â‰¥", "±");&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;use&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;new=transwrd(_newvar,'E289A5'x,'B1'x);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now your code file does not include those strange characters and so you will be able to work with it more easily and avoid confusion.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example the string you are converting 'E289A5'x is the how to represent the greater than or equal to symbol and not the plus or minus symbol.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://op.europa.eu/en/web/eu-vocabularies/formex/physical-specifications/character-encoding/mathematical-operators-and-symbols" target="_blank" rel="noopener"&gt;https://op.europa.eu/en/web/eu-vocabularies/formex/physical-specifications/character-encoding/mathematical-operators-and-symbols&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Which does not exist in the LATIN1 encoding.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So your code should be:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;new=transwrd(_newvar,'E289A5'x,'&amp;gt;=');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You still did not say what encoding your SAS session is using, just which version of SAS you were using.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2023 03:32:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-in-a-variable-contains-quot-quot-into-sas/m-p/886563#M350318</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-07-27T03:32:07Z</dc:date>
    </item>
    <item>
      <title>Re: Question-  How to read in a variable contains "±" into sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-in-a-variable-contains-quot-quot-into-sas/m-p/886642#M350353</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;:&lt;BR /&gt;Super! &lt;BR /&gt;tested and it worked. &lt;BR /&gt;&lt;BR /&gt;One typo &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;BR /&gt;new=tranwrd(newvar, 'E289A5'x, '&amp;gt;=');&lt;BR /&gt;&lt;BR /&gt;I did mention in above post. but now paste it here. &lt;BR /&gt;the SAS VERSION I am using is : &lt;BR /&gt;NOTE: SAS (r) Proprietary Software 9.4 (TS1M7)&lt;BR /&gt;thank you,&lt;BR /&gt;Purple</description>
      <pubDate>Thu, 27 Jul 2023 14:04:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-in-a-variable-contains-quot-quot-into-sas/m-p/886642#M350353</guid>
      <dc:creator>purpleclothlady</dc:creator>
      <dc:date>2023-07-27T14:04:02Z</dc:date>
    </item>
    <item>
      <title>Re: Question-  How to read in a variable contains "±" into sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-in-a-variable-contains-quot-quot-into-sas/m-p/886644#M350355</link>
      <description>&lt;P&gt;Good.&lt;/P&gt;
&lt;P&gt;You keep replying with the version of SAS&lt;/P&gt;
&lt;PRE&gt;11   %put &amp;amp;=sysvlong;
SYSVLONG=9.04.01M5P091317
&lt;/PRE&gt;
&lt;P&gt;Instead of supplying the request information, the ENCODING that is being used by the SAS session.&lt;/P&gt;
&lt;PRE&gt;12   %put %sysfunc(getoption(encoding));
WLATIN1
&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Jul 2023 14:16:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-in-a-variable-contains-quot-quot-into-sas/m-p/886644#M350355</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-07-27T14:16:35Z</dc:date>
    </item>
    <item>
      <title>Re: Question-  How to read in a variable contains "±" into sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-in-a-variable-contains-quot-quot-into-sas/m-p/886645#M350356</link>
      <description>&lt;P&gt;hi all:&lt;/P&gt;
&lt;P&gt;I posted the solution too early, thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;who helped me go through this.&lt;/P&gt;
&lt;P&gt;please use this as the &lt;FONT color="#0000FF"&gt;FINAL solution.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;CODE class=" language-sas"&gt; _new=tranwrd(_newvar, 'E289A5'x, 'B1'x);&lt;/CODE&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;Thank you,&lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;purple&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*------------------------Migrating Data from WLATIN1 to UTF-8------------------------------------
                                   REFERENCE:
 https://documentation.sas.com/doc/en/pgmsascdc/v_006/viyadatamig/p1eedruqfsgqqcn1pmjof4br5xvt.htm

/*------------------------------------------------------------------------------------------------*/
/*===Step1: Find out WHICH Encoding is on Your SAS session
    - Mine is: SAS V9.4===*/
proc options option=encoding;
run; 
/*====Step2: Use ENCODING= option to transform WLATIN1 TO UTF-8 ===*/
 data need; 
    set have(encoding=wlatin1);
   _newVar=pahdx;
  if index(compress(_newvar),"1year")&amp;gt;0;
	/*Recode ±*/
	/*per TOM suggestion, but not sure why it is working?  
	 &lt;A href="https://op.europa.eu/en/web/eu-vocabularies/formex/physical-specifications/character-encoding/mathematical-operators-and-symbols*/" target="_blank"&gt;https://op.europa.eu/en/web/eu-vocabularies/formex/physical-specifications/character-encoding/mathematical-operators-and-symbols*/&lt;/A&gt;&lt;BR /&gt;   */&lt;BR /&gt;   _new=tranwrd(_newvar, 'E289A5'x, 'B1'x);&amp;nbsp;&amp;nbsp;&lt;BR /&gt;run;&amp;nbsp;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV&gt;&amp;nbsp;&lt;CODE class=" language-sas"&gt;
&lt;/CODE&gt;&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2023 14:30:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-in-a-variable-contains-quot-quot-into-sas/m-p/886645#M350356</guid>
      <dc:creator>purpleclothlady</dc:creator>
      <dc:date>2023-07-27T14:30:56Z</dc:date>
    </item>
    <item>
      <title>Re: Question-  How to read in a variable contains "±" into sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-in-a-variable-contains-quot-quot-into-sas/m-p/886646#M350357</link>
      <description>&lt;P&gt;So that is still translating the greater than or equal to symbol into the plus minus symbol.&lt;/P&gt;
&lt;P&gt;You probably do not want to do that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are running a SAS session using WLATIN1 encoding and read a dataset that was created using the UTF-8 encoding then it would properly transcode the plus minus symbol, but it would have trouble with the actual character you seem to have, which is the greater than or equal symbol.&amp;nbsp; That is because the plus minus symbol exists in the set of 256 characters that WLATIN1 supports, but the greater than or equal symbol does not.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So to do your own transcoding you need to force SAS to not automatically transcode the strings in the UTF-8 file.&amp;nbsp; You can do that by setting the ENCODING= dataset option on the input dataset.&amp;nbsp; You could set it to the encoding your current session is using, or just set it to ANY instead.&amp;nbsp; Now the bytes in the files will by copied into the character variables without ANY changes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You will then need generate your own code to transcode ALL of the characters that use multiple bytes in UTF-8.&lt;/P&gt;
&lt;P&gt;So if you want to transcode the plus minus symbol you could use&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;transwrd(_newvar,'C281'x,'81'x)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But for the greater than or equal symbol you will need to replace it with two symbols since in WLATIN1 there is not on character that looks like that.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;tranwrd(_newvar, 'E289A5'x, '&amp;gt;=');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And remember that there are potentially many other UTF-8 characters that you are now responsible for transcoding.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So it would be much easier to just run SAS using UTF-8 encoding to deal with that dataset and then all of the characters in the file will be displayed properly without you having to do anything.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2023 14:46:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-in-a-variable-contains-quot-quot-into-sas/m-p/886646#M350357</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-07-27T14:46:27Z</dc:date>
    </item>
  </channel>
</rss>

