<?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 error while using NE in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/error-while-using-NE/m-p/534479#M146663</link>
    <description>&lt;P&gt;I am trying to categorized data based on what the last two characters are in a variable&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;rand1=rand('uniform');
rand2=rand('uniform'); 

if rand1&amp;gt;0.90 Then do; 
	if (POIDS&amp;gt;0 and substr(USAGE,2,2) IN('20','21')) then do;
		if rand2&amp;gt;0.5 then RadiusSurcharge="A";
		ELSE RadiusSurcharge="B";
		end;
	if (POIDS=0 and substr(USAGE,2,2) IN('20','21')) then do;
		if rand2&amp;gt;0.5 then RadiusSurcharge="C";
		else RadiusSurcharge="D";
		end;
end;
if rand1&amp;gt;0.90 then do;
	if (POIDS&amp;gt;0 and substr(USAGE,2,2) NE('20','21')) then do;
		if rand2&amp;gt;0.5 then RadiusSurcharge="E";
		else RadiusSurcharge="F";
		end;
	if (POIDS=0 and substr(USAGE,2,2) NE('20','21')) then do;
		if rand2&amp;lt;0.333 then RadiusSurcharge="G";
		else if rand2&amp;gt;0.333 and rand2&amp;lt;0.666 then do RadiusSurcharge="H";
		else RadiusSurcharge="I";
		end;
		end;
end;		&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The top half, I use IN function so that the obs that does contain '20' or '21' gets assigned other variables accordinly&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For the second half I am trying to use NE so that the observations that don't contain '20' or '21' but i keep getting the following errors,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;     	if (POIDS&amp;gt;0 and substr(USAGE,2,2) NE('20','21')) then do;
                                                     _
                                                     388
                                                     200
ERROR 388-185: Expecting an arithmetic operator.

ERROR 200-322: The symbol is not recognized and will be ignored.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Please advise!&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 11 Feb 2019 14:52:52 GMT</pubDate>
    <dc:creator>haider_imam</dc:creator>
    <dc:date>2019-02-11T14:52:52Z</dc:date>
    <item>
      <title>error while using NE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/error-while-using-NE/m-p/534479#M146663</link>
      <description>&lt;P&gt;I am trying to categorized data based on what the last two characters are in a variable&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;rand1=rand('uniform');
rand2=rand('uniform'); 

if rand1&amp;gt;0.90 Then do; 
	if (POIDS&amp;gt;0 and substr(USAGE,2,2) IN('20','21')) then do;
		if rand2&amp;gt;0.5 then RadiusSurcharge="A";
		ELSE RadiusSurcharge="B";
		end;
	if (POIDS=0 and substr(USAGE,2,2) IN('20','21')) then do;
		if rand2&amp;gt;0.5 then RadiusSurcharge="C";
		else RadiusSurcharge="D";
		end;
end;
if rand1&amp;gt;0.90 then do;
	if (POIDS&amp;gt;0 and substr(USAGE,2,2) NE('20','21')) then do;
		if rand2&amp;gt;0.5 then RadiusSurcharge="E";
		else RadiusSurcharge="F";
		end;
	if (POIDS=0 and substr(USAGE,2,2) NE('20','21')) then do;
		if rand2&amp;lt;0.333 then RadiusSurcharge="G";
		else if rand2&amp;gt;0.333 and rand2&amp;lt;0.666 then do RadiusSurcharge="H";
		else RadiusSurcharge="I";
		end;
		end;
end;		&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The top half, I use IN function so that the obs that does contain '20' or '21' gets assigned other variables accordinly&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For the second half I am trying to use NE so that the observations that don't contain '20' or '21' but i keep getting the following errors,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;     	if (POIDS&amp;gt;0 and substr(USAGE,2,2) NE('20','21')) then do;
                                                     _
                                                     388
                                                     200
ERROR 388-185: Expecting an arithmetic operator.

ERROR 200-322: The symbol is not recognized and will be ignored.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Please advise!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Feb 2019 14:52:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/error-while-using-NE/m-p/534479#M146663</guid>
      <dc:creator>haider_imam</dc:creator>
      <dc:date>2019-02-11T14:52:52Z</dc:date>
    </item>
    <item>
      <title>Re: error while using NE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/error-while-using-NE/m-p/534480#M146664</link>
      <description>&lt;P&gt;Correction&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
     	if (POIDS&amp;gt;0 and substr(USAGE,2,2) NOT IN ('20','21')) then do;&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;Notes:&lt;/P&gt;
&lt;P&gt;1. To filter a list that has more than one operand to evaluate, an equality operator is not appropriate . For an equality operator to work, you would have to work with just one operand&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. While you coded your IN the list correctly, all you need is NOT IN for all values that are not 20,21 to be true&lt;/P&gt;</description>
      <pubDate>Mon, 11 Feb 2019 15:03:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/error-while-using-NE/m-p/534480#M146664</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-02-11T15:03:30Z</dc:date>
    </item>
  </channel>
</rss>

