<?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: SAS Array with If Condition is not working while migrating from 9.3 to 9.4 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-Array-with-If-Condition-is-not-working-while-migrating-from/m-p/788132#M251920</link>
    <description>&lt;P&gt;In addition to &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/88384"&gt;@Shmuel&lt;/a&gt;'s suggestions, you should format your code by using the run symbol in the body tab in your post.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;

set test1;

array hra_ (*) &amp;amp;hras.;

array d_(&amp;amp;ct.);

 

do i=1 to &amp;amp;ct.;

if (((max(of hra_ (*)) = .  and min(of hra_(*)) = .)

and not missing(HRA_previous_yr))

or ((max(of hra_ (*)) = min(of hra_ (*))) and

not missing(HRA_previous_yr) and (HRA_previous_yr) = max((of hra_ (*))))

and intck('day', HRA_previous_yr, disenrollment_date) &amp;lt; 365

then do; EXCLUDE = "XYZ";

END;

END;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Try to create some normal programming syntax pattern so that your code is readable. Indentation is important to break up various statements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Where are your macro variables coming from (&amp;amp;ct., &amp;amp;hras.)? That's another question in itself.&lt;/P&gt;</description>
    <pubDate>Mon, 03 Jan 2022 16:36:15 GMT</pubDate>
    <dc:creator>maguiremq</dc:creator>
    <dc:date>2022-01-03T16:36:15Z</dc:date>
    <item>
      <title>SAS Array with If Condition is not working while migrating from 9.3 to 9.4</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Array-with-If-Condition-is-not-working-while-migrating-from/m-p/788129#M251917</link>
      <description>&lt;P&gt;Please help in validating this code. In 9.4 I am not able to get correct value of EXCLUDE in the output.&lt;/P&gt;&lt;P&gt;Seems like there is some error around 'and not missing'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;set test1;&lt;/P&gt;&lt;P&gt;array hra_ (*) &amp;amp;hras.;&lt;/P&gt;&lt;P&gt;array d_(&amp;amp;ct.);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;do i=1 to &amp;amp;ct.;&lt;/P&gt;&lt;P&gt;if (((max(of hra_ (*)) = .&amp;nbsp; and min(of hra_(*)) = .)&lt;/P&gt;&lt;P&gt;and not missing(HRA_previous_yr))&lt;/P&gt;&lt;P&gt;or ((max(of hra_ (*)) = min(of hra_ (*))) and&lt;/P&gt;&lt;P&gt;not missing(HRA_previous_yr) and (HRA_previous_yr) = max((of hra_ (*))))&lt;/P&gt;&lt;P&gt;and intck('day', HRA_previous_yr, disenrollment_date) &amp;lt; 365&lt;/P&gt;&lt;P&gt;then do; EXCLUDE = "XYZ";&lt;/P&gt;&lt;P&gt;END;&lt;/P&gt;&lt;P&gt;END;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jan 2022 16:21:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Array-with-If-Condition-is-not-working-while-migrating-from/m-p/788129#M251917</guid>
      <dc:creator>San_rise</dc:creator>
      <dc:date>2022-01-03T16:21:25Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Array with If Condition is not working while migrating from 9.3 to 9.4</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Array-with-If-Condition-is-not-working-while-migrating-from/m-p/788130#M251918</link>
      <description>&lt;P&gt;You should provide some test data and the log of your run.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What do you mean by&amp;nbsp;&lt;STRONG&gt;&lt;SPAN&gt;&amp;nbsp;EXCLUDE = "XYZ";&lt;/SPAN&gt;&lt;/STRONG&gt; ?&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jan 2022 16:29:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Array-with-If-Condition-is-not-working-while-migrating-from/m-p/788130#M251918</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2022-01-03T16:29:43Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Array with If Condition is not working while migrating from 9.3 to 9.4</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Array-with-If-Condition-is-not-working-while-migrating-from/m-p/788131#M251919</link>
      <description>&lt;P&gt;Hey&lt;/P&gt;&lt;P&gt;I am getting the output, but the value in the Variable EXCLUDE is not coming as "XYZ". Suspecting that the IF condition has some error.&lt;/P&gt;&lt;P&gt;EXCLUDE = "XYZ" is a command given to create variable EXCLUDE with value as "XYZ".&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jan 2022 16:34:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Array-with-If-Condition-is-not-working-while-migrating-from/m-p/788131#M251919</guid>
      <dc:creator>San_rise</dc:creator>
      <dc:date>2022-01-03T16:34:05Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Array with If Condition is not working while migrating from 9.3 to 9.4</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Array-with-If-Condition-is-not-working-while-migrating-from/m-p/788132#M251920</link>
      <description>&lt;P&gt;In addition to &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/88384"&gt;@Shmuel&lt;/a&gt;'s suggestions, you should format your code by using the run symbol in the body tab in your post.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;

set test1;

array hra_ (*) &amp;amp;hras.;

array d_(&amp;amp;ct.);

 

do i=1 to &amp;amp;ct.;

if (((max(of hra_ (*)) = .  and min(of hra_(*)) = .)

and not missing(HRA_previous_yr))

or ((max(of hra_ (*)) = min(of hra_ (*))) and

not missing(HRA_previous_yr) and (HRA_previous_yr) = max((of hra_ (*))))

and intck('day', HRA_previous_yr, disenrollment_date) &amp;lt; 365

then do; EXCLUDE = "XYZ";

END;

END;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Try to create some normal programming syntax pattern so that your code is readable. Indentation is important to break up various statements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Where are your macro variables coming from (&amp;amp;ct., &amp;amp;hras.)? That's another question in itself.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jan 2022 16:36:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Array-with-If-Condition-is-not-working-while-migrating-from/m-p/788132#M251920</guid>
      <dc:creator>maguiremq</dc:creator>
      <dc:date>2022-01-03T16:36:15Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Array with If Condition is not working while migrating from 9.3 to 9.4</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Array-with-If-Condition-is-not-working-while-migrating-from/m-p/788135#M251922</link>
      <description>Please post example data. Use this site if you need to figure it out how to get your current data set into a DATA step.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/" target="_blank"&gt;https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Please also post your log. We can't tell what's going on without your log.</description>
      <pubDate>Mon, 03 Jan 2022 16:37:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Array-with-If-Condition-is-not-working-while-migrating-from/m-p/788135#M251922</guid>
      <dc:creator>maguiremq</dc:creator>
      <dc:date>2022-01-03T16:37:53Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Array with If Condition is not working while migrating from 9.3 to 9.4</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Array-with-If-Condition-is-not-working-while-migrating-from/m-p/788139#M251924</link>
      <description>&lt;P&gt;Thank you for spacing the code. Here is the Log&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="San_rise_0-1641228615402.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/67084iAD4E82145C3FCC70/image-size/medium?v=v2&amp;amp;px=400" role="button" title="San_rise_0-1641228615402.png" alt="San_rise_0-1641228615402.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jan 2022 16:50:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Array-with-If-Condition-is-not-working-while-migrating-from/m-p/788139#M251924</guid>
      <dc:creator>San_rise</dc:creator>
      <dc:date>2022-01-03T16:50:55Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Array with If Condition is not working while migrating from 9.3 to 9.4</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Array-with-If-Condition-is-not-working-while-migrating-from/m-p/788141#M251925</link>
      <description>&lt;P&gt;If the code is unchanged and it used to work and now it doesn't then the DATA has changed.&amp;nbsp; Either the input dataset or the two input macro variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code is confusing with extra parentheses that are not needed and it looks like you are missing some parentheses that are probably needed.&amp;nbsp; It looks like you have a logical expression in the form&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;A or B and C&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Did you mean&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;(A or B) and C&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or did you mean&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;A or (B and C)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Please explain in words what you condition is trying to detect.&lt;/P&gt;
&lt;P&gt;Note to test if all of the values are missing just use the N( ) function. If N(of HRA_[*]) is zero then all of the variables are missing.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jan 2022 17:05:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Array-with-If-Condition-is-not-working-while-migrating-from/m-p/788141#M251925</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-01-03T17:05:25Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Array with If Condition is not working while migrating from 9.3 to 9.4</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Array-with-If-Condition-is-not-working-while-migrating-from/m-p/788146#M251929</link>
      <description>&lt;P&gt;Condition 1: (max(HRA) = missing&amp;nbsp; and min(HRA) = missing) and HRA_prev_yr is not missing&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;OR&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Condition 2: max(hra) = min(HRA) and&amp;nbsp;HRA_prev_yr is not missing and HRA_prev_yr = max(HRA)&lt;/P&gt;&lt;P&gt;and intck('day',hra_prev_yr,disenrollment_date) &amp;lt;365&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So it is A OR B.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note: HRA here is macros with arrays ranging from 1 to 41 and is in date format.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jan 2022 17:26:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Array-with-If-Condition-is-not-working-while-migrating-from/m-p/788146#M251929</guid>
      <dc:creator>San_rise</dc:creator>
      <dc:date>2022-01-03T17:26:53Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Array with If Condition is not working while migrating from 9.3 to 9.4</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Array-with-If-Condition-is-not-working-while-migrating-from/m-p/788147#M251930</link>
      <description>&lt;P&gt;First thing: What the heck is that do i= loop in there for? Your shown code would loop over the &lt;STRONG&gt;exact&lt;/STRONG&gt; &lt;STRONG&gt;same&lt;/STRONG&gt; values however many times the value of &amp;amp;Ct may be. One almost might guess that once upon a time this iterated over the values of one of the arrays testing each value but this code doesn't. You aren't referencing either of the arrays using i as an index.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hint: If an array of numeric values returns missing, as in&lt;/P&gt;
&lt;PRE&gt;max(of hra_ (*)) = .&lt;/PRE&gt;
&lt;P&gt;the min will ALWAYS be missing as the only way the Max and Min functions return missing is when all values are missing.&lt;/P&gt;
&lt;P&gt;So the bit of&lt;/P&gt;
&lt;PRE&gt;and min(of hra_(*)) = .&lt;/PRE&gt;
&lt;P&gt;is not needed and adds additional () that aren't actually needed after removing the min. Alternate code could also be to test if all values are missing.&lt;/P&gt;
&lt;PRE&gt;nmiss(of hra_(*)) = dim(hra_a)&lt;/PRE&gt;
&lt;P&gt;The bit of&lt;/P&gt;
&lt;PRE&gt;max(of hra_ (*)) = min(of hra_ (*))&lt;/PRE&gt;
&lt;P&gt;Could be replaced with&lt;/P&gt;
&lt;PRE&gt;Range( of hra_(*))=0&lt;/PRE&gt;
&lt;P&gt;Range is largest non-missing minus smallest non-missing. So when the max and min are the same the range is 0.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note: You may also need to consider Leap years some where if that is why you are hard coding 365.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jan 2022 17:29:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Array-with-If-Condition-is-not-working-while-migrating-from/m-p/788147#M251930</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-01-03T17:29:04Z</dc:date>
    </item>
  </channel>
</rss>

