<?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: Flag in PROC SQL syntax no longer working in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Flag-in-PROC-SQL-syntax-no-longer-working/m-p/299749#M63259</link>
    <description>&lt;P&gt;In your log there is a note: &amp;nbsp;"Numeric values have been converted to characters";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It seems as MC041 in diabetes dataset was defined as CHAR type&lt;/P&gt;&lt;P&gt;while MC041 in ami was defined as numeric ? &amp;nbsp;Is it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For testing AMI better do:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; if ami in (. &amp;nbsp;41001 41011 ... ) then ... ; &amp;nbsp; /* see PG Stats answer , and pay attention:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; as ami is numeric you cant check for blank but for missing value */&lt;/P&gt;</description>
    <pubDate>Wed, 21 Sep 2016 05:36:59 GMT</pubDate>
    <dc:creator>Shmuel</dc:creator>
    <dc:date>2016-09-21T05:36:59Z</dc:date>
    <item>
      <title>Flag in PROC SQL syntax no longer working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flag-in-PROC-SQL-syntax-no-longer-working/m-p/299715#M63246</link>
      <description>&lt;P&gt;Hey all,&lt;/P&gt;&lt;P&gt;I have been working on aggregating codes and creating flags for diagnosis data. I wrote one that worked fine but when I tried to apply it to another diagnosis, it does not work. Any help would be much appreciated.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the original syntax:&lt;/P&gt;&lt;P&gt;DATA WANT;&lt;BR /&gt;SET HAVE;&lt;BR /&gt;DIABETES = 0;&lt;BR /&gt;IF indexW("E0800" || " " || "E0801" || " " || "E0810" || " " || "E0811", MC041) &amp;gt; 0 then DIABETES = 1;&lt;BR /&gt;ELSE IF DIABETES = 0 THEN DELETE;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;New syntax&lt;/P&gt;&lt;P&gt;DATA WANT;&lt;/P&gt;&lt;P&gt;SET NEED;&lt;/P&gt;&lt;P&gt;AMI = 0;&lt;BR /&gt;if indexW("41001" || " " || "41011" || " " || "41021" || " " || "41031" || " " || "41041", MC041) &amp;gt; 0 then AMI = 1;&lt;BR /&gt;ELSE IF AMI = 0 THEN DELETE;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Sep 2016 00:11:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flag-in-PROC-SQL-syntax-no-longer-working/m-p/299715#M63246</guid>
      <dc:creator>MHP</dc:creator>
      <dc:date>2016-09-21T00:11:49Z</dc:date>
    </item>
    <item>
      <title>Re: Flag in PROC SQL syntax no longer working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flag-in-PROC-SQL-syntax-no-longer-working/m-p/299717#M63248</link>
      <description>&lt;P&gt;"it does not work" doesn't actually tell us what doesn't work.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How doesn't it work.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, consider using WHICHC instead, it's a bit easier to read for one. Or at least CATX to create the string to search for.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data diabetes;
set have;
diabetes=0;
if whichc(MC041, "E0800", "E0801", "E0810", "E0811")&amp;gt;0 then diabetes =1;
else delete;
run;

data ami;
set have;

ami=0;
if whichc(MC041, "41001", "41011", "41021", "41031")&amp;gt;0 then ami =1;
else delete;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Actually the trick is in your log.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your first dataset references PD and only outputs records for Diabetes.&lt;/P&gt;
&lt;P&gt;You then check for the AMI record from the data set from step 1. If this is correct it's likely your condition is never met.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or you need to switch to a different source dataset.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS. Please include your code and log in your post not as an attachment.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Sep 2016 00:22:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flag-in-PROC-SQL-syntax-no-longer-working/m-p/299717#M63248</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-09-21T00:22:54Z</dc:date>
    </item>
    <item>
      <title>Re: Flag in PROC SQL syntax no longer working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flag-in-PROC-SQL-syntax-no-longer-working/m-p/299726#M63250</link>
      <description>&lt;P&gt;The error is not in the code that you presented. It is elsewhere in the code or in the data. Nevertheless, your code could be made simpler and clearer:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data diabetes;
set have;
diabetes = MC041 in ("E0800", "E0801", "E0810", "E0811");
if diabetes;
run;

data ami;
set have;
ami = MC041 in ("41001", "41011", "41021", "41031");
if ami;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 21 Sep 2016 02:22:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flag-in-PROC-SQL-syntax-no-longer-working/m-p/299726#M63250</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-09-21T02:22:00Z</dc:date>
    </item>
    <item>
      <title>Re: Flag in PROC SQL syntax no longer working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flag-in-PROC-SQL-syntax-no-longer-working/m-p/299749#M63259</link>
      <description>&lt;P&gt;In your log there is a note: &amp;nbsp;"Numeric values have been converted to characters";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It seems as MC041 in diabetes dataset was defined as CHAR type&lt;/P&gt;&lt;P&gt;while MC041 in ami was defined as numeric ? &amp;nbsp;Is it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For testing AMI better do:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; if ami in (. &amp;nbsp;41001 41011 ... ) then ... ; &amp;nbsp; /* see PG Stats answer , and pay attention:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; as ami is numeric you cant check for blank but for missing value */&lt;/P&gt;</description>
      <pubDate>Wed, 21 Sep 2016 05:36:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flag-in-PROC-SQL-syntax-no-longer-working/m-p/299749#M63259</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-09-21T05:36:59Z</dc:date>
    </item>
  </channel>
</rss>

