<?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: Flagging an error for only specific variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Flagging-an-error-for-only-specific-variables/m-p/454711#M284208</link>
    <description>&lt;P&gt;Hello! thanks for the reply &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; I was originally thinking I would do something like that but the problem is that the table is actually huge and constantly changing, so I need to somehow get around writing all of the 'ABC codes'&lt;/P&gt;</description>
    <pubDate>Tue, 17 Apr 2018 12:24:46 GMT</pubDate>
    <dc:creator>sashelp123</dc:creator>
    <dc:date>2018-04-17T12:24:46Z</dc:date>
    <item>
      <title>Flagging an error for only specific variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-an-error-for-only-specific-variables/m-p/454558#M284204</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to write a code for a data set that will always be changing. In my code, there is a macro where you put in the province code, and then a raw data file is imported and checked for errors. I want the program to flag it as an error, if there is an ABC code that is not an option for that particular province. For example, if the raw data file is say AB and the ABC code is not in 'A" or "KK" than I want that to&amp;nbsp;be flagged&amp;nbsp;as an error. So basically, what counts as an error will change based on the province code. Or if for example the "ABC Code" is R, and it is SK, that is no error, but if it is AB that is an error.&amp;nbsp;And this table is always changing. But in essence, I want it to be an error, only if there is not an "ABC Code" for the specific province being checked.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It looks something like this:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;Province Code&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;ABC Code&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;AB&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;A&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;AB&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;KK&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;BC&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;C&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;SK&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;R&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;NS&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;T&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Mon, 16 Apr 2018 20:11:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-an-error-for-only-specific-variables/m-p/454558#M284204</guid>
      <dc:creator>sashelp123</dc:creator>
      <dc:date>2018-04-16T20:11:06Z</dc:date>
    </item>
    <item>
      <title>Re: Flagging an error for only specific variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-an-error-for-only-specific-variables/m-p/454562#M284205</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if province_code='AB' and abc_code not in ('A','KK') then flag=1;
else if province_code='SK' and abc_code not in ( ... ) then flag=1; /* You have to fill in the abc_codes for SK */&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Apr 2018 20:19:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-an-error-for-only-specific-variables/m-p/454562#M284205</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-04-16T20:19:58Z</dc:date>
    </item>
    <item>
      <title>Re: Flagging an error for only specific variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-an-error-for-only-specific-variables/m-p/454566#M284206</link>
      <description>&lt;P&gt;A user defined format is a great idea here.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can make one for each province, with OTHER/MISSING flagged as needed, and then any that don't meet your list will become ERROR that you can flag or modify as needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can create formats from a data set so this can be entirely dynamic as your lists changes as needed.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Lets assume you have a macro variable PROV that's set to AB, and you then have a format called AB_valid_fmt, you can use PUTC to check the values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;check = putc(ABC, "&amp;amp;PROV_valid_fmt.");
if check = "ERROR" then ...&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Apr 2018 20:26:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-an-error-for-only-specific-variables/m-p/454566#M284206</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-04-16T20:26:02Z</dc:date>
    </item>
    <item>
      <title>Re: Flagging an error for only specific variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-an-error-for-only-specific-variables/m-p/454635#M284207</link>
      <description>&lt;P&gt;Create a table with the valid pairings, and do a join/merge with that table. If abc_code is not missing and there's no match, you have an error.&lt;/P&gt;
&lt;P&gt;That way you get intelligent code (does not need to be changed) out of intelligent data.&lt;/P&gt;
&lt;P&gt;Alternatively, you can create a format out of that control dataset (make a compound value out of province and abc_code), and apply that to a compound of province and abc_code in your main dataset. Then you don't need the join/merge.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Apr 2018 06:53:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-an-error-for-only-specific-variables/m-p/454635#M284207</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-04-17T06:53:07Z</dc:date>
    </item>
    <item>
      <title>Re: Flagging an error for only specific variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-an-error-for-only-specific-variables/m-p/454711#M284208</link>
      <description>&lt;P&gt;Hello! thanks for the reply &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; I was originally thinking I would do something like that but the problem is that the table is actually huge and constantly changing, so I need to somehow get around writing all of the 'ABC codes'&lt;/P&gt;</description>
      <pubDate>Tue, 17 Apr 2018 12:24:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-an-error-for-only-specific-variables/m-p/454711#M284208</guid>
      <dc:creator>sashelp123</dc:creator>
      <dc:date>2018-04-17T12:24:46Z</dc:date>
    </item>
  </channel>
</rss>

