<?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: Simple programming problem in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Simple-programming-problem/m-p/724798#M225054</link>
    <description>&lt;P&gt;Please supply your example data in usable form, like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data temp05;
input exporter $ importer $;
datalines;
ABW ABW
AFG AFG
SAU SAU
;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Simplify your conditions, by using the IN operator and by using the fact that a boolean true is 1 and false is 0:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data coun1;
set temp05;
egcc = (exporter in ("SAU","BHR","QAT","KWT","OMN","ARE"));
igcc = (importer in ("SAU","BHR","QAT","KWT","OMN","ARE"));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This flags the first two obs of my example dataset with 0's.&lt;/P&gt;</description>
    <pubDate>Tue, 09 Mar 2021 09:52:43 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2021-03-09T09:52:43Z</dc:date>
    <item>
      <title>Simple programming problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simple-programming-problem/m-p/724793#M225050</link>
      <description>&lt;P&gt;Hello everybody,&lt;/P&gt;
&lt;P&gt;I have a simple code that is not doing what is supposed to and I am baffled...!&amp;nbsp; Here is the simplified version of the&amp;nbsp; code - I am explaining immediately after&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data coun1; set temp05;
if exporter="SAU" or exporter="BHR" or exporter="QAT" or exporter="KWT" or exporter="OMN" or exporter="ARE" then EGCC=1; else EGCC=0;
if importer="SAU" or importer="BHR" or importer="QAT" or importer="KWT" or importer="OMN" or exporter="ARE" then IGCC=1; else IGCC=0;
run;

data coun2; set coun1;      &lt;BR /&gt;if year=2015 or year =2005;  proc sort ;by year; &lt;BR /&gt;run;&lt;BR /&gt;
data igcc2; set coun2;        &lt;BR /&gt;if egcc=1 and igcc=1;   &lt;BR /&gt;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;_____________________&lt;/P&gt;
&lt;P&gt;The problem is that the final file (igcc2) looks as follows &lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="del.jpg" style="width: 974px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/55712i224E2B3C92782E81/image-size/large?v=v2&amp;amp;px=999" role="button" title="del.jpg" alt="del.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;which means that it is coding importers such as "ABW" and "AFG" with an IGCC=1.&lt;/P&gt;
&lt;P&gt;Could someone explain what is going on here?&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Mar 2021 09:31:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simple-programming-problem/m-p/724793#M225050</guid>
      <dc:creator>Dim13</dc:creator>
      <dc:date>2021-03-09T09:31:18Z</dc:date>
    </item>
    <item>
      <title>Re: Simple programming problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simple-programming-problem/m-p/724797#M225053</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;On the second if condition, you have a copying mistake. you have 'exporter="ARE"' that's the issue&lt;/P&gt;</description>
      <pubDate>Tue, 09 Mar 2021 09:48:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simple-programming-problem/m-p/724797#M225053</guid>
      <dc:creator>Athenkosi</dc:creator>
      <dc:date>2021-03-09T09:48:45Z</dc:date>
    </item>
    <item>
      <title>Re: Simple programming problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simple-programming-problem/m-p/724798#M225054</link>
      <description>&lt;P&gt;Please supply your example data in usable form, like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data temp05;
input exporter $ importer $;
datalines;
ABW ABW
AFG AFG
SAU SAU
;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Simplify your conditions, by using the IN operator and by using the fact that a boolean true is 1 and false is 0:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data coun1;
set temp05;
egcc = (exporter in ("SAU","BHR","QAT","KWT","OMN","ARE"));
igcc = (importer in ("SAU","BHR","QAT","KWT","OMN","ARE"));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This flags the first two obs of my example dataset with 0's.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Mar 2021 09:52:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simple-programming-problem/m-p/724798#M225054</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-03-09T09:52:43Z</dc:date>
    </item>
    <item>
      <title>Re: Simple programming problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simple-programming-problem/m-p/724799#M225055</link>
      <description>&lt;P&gt;Just a small tip&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Instead of using multiple or's you can use the 'IN' operator that will make your code more compact.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="sas"&gt;data coun1; 
    set temp05;
    if exporter in ("SAU" "BHR" "QAT" "KWT" "OMN" "ARE") then EGCC=1; 
    else EGCC=0;
    if importer in ("SAU" "BHR" "QAT" "KWT" "OMN" "ARE") then IGCC=1; 
    else IGCC=0;
run;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Mar 2021 09:53:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simple-programming-problem/m-p/724799#M225055</guid>
      <dc:creator>Athenkosi</dc:creator>
      <dc:date>2021-03-09T09:53:49Z</dc:date>
    </item>
    <item>
      <title>Re: Simple programming problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simple-programming-problem/m-p/724800#M225056</link>
      <description>Thank you!!!.... I guess staring at this for the last 3 hours did not help!  It is always the simplest problems&lt;BR /&gt;thanks again.</description>
      <pubDate>Tue, 09 Mar 2021 09:54:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simple-programming-problem/m-p/724800#M225056</guid>
      <dc:creator>Dim13</dc:creator>
      <dc:date>2021-03-09T09:54:29Z</dc:date>
    </item>
    <item>
      <title>Re: Simple programming problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simple-programming-problem/m-p/724802#M225057</link>
      <description>Thank you.  Both solutions worked fine.</description>
      <pubDate>Tue, 09 Mar 2021 09:55:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simple-programming-problem/m-p/724802#M225057</guid>
      <dc:creator>Dim13</dc:creator>
      <dc:date>2021-03-09T09:55:34Z</dc:date>
    </item>
  </channel>
</rss>

