<?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: How to use array and calculate date variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-array-and-calculate-date-variable/m-p/948678#M371158</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/253321"&gt;@CathyVI&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below code populates variable FLG with values that match your variable N in the sample data.&lt;/P&gt;
&lt;P&gt;Please add additional rows/data for use cases where you believe below code won't return what you desire. Given the already ongoing discussion I believe sample data with desired outcome that covers all your cases will get us faster to your desired solution.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
    input ID $ First_Ischemic :date9. First_Hemorrhagic :date9. R_Seizure_1 :date9. R_Seizure_2 :date9. R_Seizure_3 :date9. R_Seizure_4 :date9. n $;
    format First_Ischemic First_Hemorrhagic R_Seizure_1 R_Seizure_2 R_Seizure_3 R_Seizure_4 date9.;
    datalines;
11386 23SEP2004 10FEB2020 . . . 12AUG2015 no
11396 23SEP2004 10FEB2004 . . . 11FEB2020 yes
11427 11SEP2010 09AUG2010 10SEP2010 03FEB2012 . . yes
12666 . 18SEP2006 20JUN2002 . . . no
20485 15JUL2019 . . . 15AUG2009 25JUL2010 no
23434 . 18OCT2002 21JUN2003 . . . yes
32462 13AUG2014 . 12AUG2014 20JUN2002 . . no
34627 01DEC2009 30NOV2009 . 10FEB2010 . . yes
;
run;

proc format;
  value yesno (default=3)
    1='yes'
    0='no'
    other='n/a'
    ;
run;

data want;
  set have;
  length flg 3;
  format flg yesno.;
  flg = max(of R_Seizure_:) &amp;gt; max(First_Ischemic,First_Hemorrhagic); 
run;

proc print data=want;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1729640322070.png" style="width: 821px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/101717i34B58A0291BE8BAB/image-dimensions/821x240?v=v2" width="821" height="240" role="button" title="Patrick_0-1729640322070.png" alt="Patrick_0-1729640322070.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 22 Oct 2024 23:47:06 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2024-10-22T23:47:06Z</dc:date>
    <item>
      <title>How to use array and calculate date variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-array-and-calculate-date-variable/m-p/948630#M371138</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am unable to produce the follow output below.&lt;BR /&gt;I tried to use an array for my variable because in the real data, I have R_Seizure_1 to R_Seizure_20.&lt;BR /&gt;Writing R_Seizure_1=. or R_Seizure_2=. or R_Seizure_3=. all the way to R_Seizure_20 is not efficient.&lt;BR /&gt;I want SAS to ignore the missing variable.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data have;
input ID $6. First_Ischemic  First_Hemorrhagic R_Seizure_1 R_Seizure_2 R_Seizure_3 R_Seizure_4 ;
format First_Ischemic  First_Hemorrhagic  R_Seizure_1 R_Seizure_2 R_Seizure_3 R_Seizure_4 date9.;
informat First_Ischemic  First_Hemorrhagic  R_Seizure_1 R_Seizure_2 R_Seizure_3 R_Seizure_4 date9.;
datalines;
011396   23SEP2004  10FEB2004  .   .   .   11FEB2020 
034627   01DEC2009  30NOV2009  .   10FEB2010  .   .     
011427   11SEP2010   09AUG2010   10SEP2010   03FEB2012   .   . 
012666   .   18SEP2006   20JUN2002   .   .   .
023434   .   18OCT2002   21JUN2003   .   .   . 
020485   15JUL2019   .   .   .   15AUG2009   25JUL2010
032462   13AUG2014   .   12AUG2014    20JUN2002   .   .
011386   23SEP2004  10FEB2020  .   .   .   12AUG2015

;
run;
proc sort data=have; by id; run;

data want;
set have;
by id;
array vars R_Seizure_1--R_Seizure_4;
if R_Seizure_1--R_Seizure_4=. or First_Ischemic=. or First_Hemorrhagic=. then n='N/A';
if R_Seizure_1--R_Seizure_4 ne .  then do;
if R_Seizure_1--R_Seizure_4 &amp;gt; First_Ischemic or First_Hemorrhagic then n=1;
else n=0;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Expected output&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;First_Ischemic&lt;/TD&gt;&lt;TD&gt;First_Hemorrhagic&lt;/TD&gt;&lt;TD&gt;R_Seizure_1&lt;/TD&gt;&lt;TD&gt;R_Seizure_2&lt;/TD&gt;&lt;TD&gt;R_Seizure_3&lt;/TD&gt;&lt;TD&gt;R_Seizure_4&lt;/TD&gt;&lt;TD&gt;n&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;11386&lt;/TD&gt;&lt;TD&gt;&lt;CODE class=""&gt;23SEP2004&lt;/CODE&gt;&lt;/TD&gt;&lt;TD&gt;&lt;CODE class=""&gt;10FEB2020&lt;/CODE&gt;&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;&lt;CODE class=""&gt;12AUG2015&lt;/CODE&gt;&lt;/TD&gt;&lt;TD&gt;no&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;11396&lt;/TD&gt;&lt;TD&gt;&lt;CODE class=""&gt;23SEP2004&lt;/CODE&gt;&lt;/TD&gt;&lt;TD&gt;&lt;CODE class=""&gt;10FEB2004 &lt;/CODE&gt;&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;&lt;CODE class=""&gt;11FEB2020&lt;/CODE&gt;&lt;/TD&gt;&lt;TD&gt;yes&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;11427&lt;/TD&gt;&lt;TD&gt;&lt;CODE class=""&gt;11SEP2010&lt;/CODE&gt;&lt;/TD&gt;&lt;TD&gt;&lt;CODE class=""&gt;09AUG2010&lt;/CODE&gt;&lt;/TD&gt;&lt;TD&gt;&lt;CODE class=""&gt;10SEP2010&lt;/CODE&gt;&lt;/TD&gt;&lt;TD&gt;&lt;CODE class=""&gt;03FEB2012&lt;/CODE&gt;&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;yes&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12666&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;&lt;CODE class=""&gt;18SEP2006&lt;/CODE&gt;&lt;/TD&gt;&lt;TD&gt;&lt;CODE class=""&gt;20JUN2002&lt;/CODE&gt;&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;no&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;20485&lt;/TD&gt;&lt;TD&gt;&lt;CODE class=""&gt;15JUL2019 &lt;/CODE&gt;&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;&lt;CODE class=""&gt;15AUG2009&lt;/CODE&gt;&lt;/TD&gt;&lt;TD&gt;&lt;CODE class=""&gt;25JUL2010&lt;/CODE&gt;&lt;/TD&gt;&lt;TD&gt;no&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;23434&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;&lt;CODE class=""&gt;18OCT2002&lt;/CODE&gt;&lt;/TD&gt;&lt;TD&gt;&lt;CODE class=""&gt;21JUN2003&lt;/CODE&gt;&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;yes&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;32462&lt;/TD&gt;&lt;TD&gt;&lt;CODE class=""&gt;13AUG2014&lt;/CODE&gt;&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;&lt;CODE class=""&gt;12AUG2014 &lt;/CODE&gt;&lt;/TD&gt;&lt;TD&gt;&lt;CODE class=""&gt;20JUN2002&lt;/CODE&gt;&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;no&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;34627&lt;/TD&gt;&lt;TD&gt;&lt;CODE class=""&gt;01DEC2009&lt;/CODE&gt;&lt;/TD&gt;&lt;TD&gt;&lt;CODE class=""&gt;30NOV2009&lt;/CODE&gt;&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;&lt;CODE class=""&gt;10FEB2010&lt;/CODE&gt;&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;yes&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Tue, 22 Oct 2024 17:35:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-array-and-calculate-date-variable/m-p/948630#M371138</guid>
      <dc:creator>CathyVI</dc:creator>
      <dc:date>2024-10-22T17:35:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to use array and calculate date variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-array-and-calculate-date-variable/m-p/948631#M371139</link>
      <description>&lt;P&gt;Replace this&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;array vars R_Seizure_1--R_Seizure_4;
if R_Seizure_1--R_Seizure_4=. or First_Ischemic=. or First_Hemorrhagic=. then n='N/A';
if R_Seizure_1--R_Seizure_4 ne .  then do;
if R_Seizure_1--R_Seizure_4 &amp;gt; First_Ischemic or First_Hemorrhagic then n=1;
else n=0;&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;with this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array vars R_Seizure_1--R_Seizure_4;
if n(of vars{*})=0 and First_Ischemic=. or First_Hemorrhagic=. then n='N/A';
if n(of vars{*})=4 then do;
/* if R_Seizure_1--R_Seizure_4 &amp;gt; First_Ischemic or First_Hemorrhagic then n=1; else n=0; */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Above, one line is commented out because I cannot figure out what you are trying to do (and in fact, I am guessing about the other lines as well). I'm pretty sure this has been requested from you in the past: please DESCRIBE what you are doing in words. DESCRIBE what each line is supposed to be doing. Do NOT make us guess what your incorrect code is supposed to be doing. Do this for every post in the future, as well as for this one.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Oct 2024 17:44:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-array-and-calculate-date-variable/m-p/948631#M371139</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-10-22T17:44:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to use array and calculate date variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-array-and-calculate-date-variable/m-p/948632#M371140</link>
      <description>&lt;P&gt;This is not valid syntax:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if R_Seizure_1--R_Seizure_4=.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The = comparison operator can only compare 2 values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please explain in words what test you are trying to perform.&lt;/P&gt;
&lt;P&gt;Do you want the result to be TRUE when ALL of the values are missing?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;n(of R_Seizure_1--R_Seizure_4) = 0&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or any ANY of the values are missing?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;nmiss(of R_Seizure_1--R_Seizure_4) &amp;gt; 0&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or even simpler just:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;nmiss(of R_Seizure_1--R_Seizure_4)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;since in boolean expressions SAS will treat 0 (or missing) as FALSE and any other number as TRUE.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Oct 2024 17:44:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-array-and-calculate-date-variable/m-p/948632#M371140</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-10-22T17:44:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to use array and calculate date variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-array-and-calculate-date-variable/m-p/948636#M371143</link>
      <description>&lt;P&gt;Is the variable N supposed to be numeric or character? The code you have written creates it as character as first use is n='N/A'; Then you use statements that try to assign numeric values which gets you into the automatic conversion of numeric.&lt;/P&gt;
&lt;P&gt;If you want to display 'N/A' for a numeric variable then assign a special missing and then create custom format to display that.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Oct 2024 18:00:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-array-and-calculate-date-variable/m-p/948636#M371143</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-10-22T18:00:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to use array and calculate date variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-array-and-calculate-date-variable/m-p/948639#M371145</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;Sorry. I wrote an extensive message but I made a&amp;nbsp; little cut/paste mistake and I could not undo all the messages on this community note.&lt;/P&gt;&lt;P&gt;What I want is to find when&amp;nbsp;&lt;/P&gt;&lt;P&gt;R_Seizure_1 or R_Seizure_1 or R_Seizure_3 or R_Seizure_4&amp;nbsp;is&amp;nbsp;greater&amp;nbsp;than First_Ischemic or First_Hemorrhagic date and make a variable called N to be 'Yes'&lt;BR /&gt;&amp;nbsp;In the line you comment out, I want the N to indicate if any seizure date comes before the first stroke dates (ischemic or hemorrhagic) if this is true then seizure is a post_stroke (n=yes) but if seizure date comes after either stroke dates then the post_stroke (n=no).&lt;/P&gt;&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;&amp;nbsp; I want the default&amp;nbsp;nmiss(of R_Seizure_1--R_Seizure_4). as if I want sas to make ANY missing=0, I would loose alot of record to missing. Only when ALL of the seizure is miss is when SAS should consider output as missing.&lt;BR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;I want N to be a character variable&lt;/P&gt;</description>
      <pubDate>Tue, 22 Oct 2024 18:09:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-array-and-calculate-date-variable/m-p/948639#M371145</guid>
      <dc:creator>CathyVI</dc:creator>
      <dc:date>2024-10-22T18:09:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to use array and calculate date variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-array-and-calculate-date-variable/m-p/948641#M371146</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/253321"&gt;@CathyVI&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;Sorry. I wrote an extensive message but I made a&amp;nbsp; little cut/paste mistake and I could not undo all the messages on this community note.&lt;/P&gt;
&lt;P&gt;What I want is to find when&amp;nbsp;&lt;/P&gt;
&lt;P&gt;R_Seizure_1 or R_Seizure_1 or R_Seizure_3 or R_Seizure_4&amp;nbsp;is&amp;nbsp;greater&amp;nbsp;than First_Ischemic or First_Hemorrhagic date and make a variable called N to be 'Yes'&lt;BR /&gt;&amp;nbsp;In the line you comment out, I want the N to indicate if any seizure date comes before the first stroke dates (ischemic or hemorrhagic) if this is true then seizure is a post_stroke (n=yes) but if seizure date comes after either stroke dates then the post_stroke (n=no).&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You contradict yourself.&lt;/P&gt;
&lt;P&gt;In the first sentence, you say you want "Yes" when any seizure comes after a stroke, but then you say at the end of the second sentence that it should be "No". Please make up your mind.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Oct 2024 19:04:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-array-and-calculate-date-variable/m-p/948641#M371146</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2024-10-22T19:04:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to use array and calculate date variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-array-and-calculate-date-variable/m-p/948644#M371148</link>
      <description>Not invalid, just incorrect.&lt;BR /&gt;R_Seizure_1--R_Seizure_4 actually is equivalent to &lt;BR /&gt;R_Seizure_1+R_Seizure_4&lt;BR /&gt;</description>
      <pubDate>Tue, 22 Oct 2024 19:12:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-array-and-calculate-date-variable/m-p/948644#M371148</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2024-10-22T19:12:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to use array and calculate date variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-array-and-calculate-date-variable/m-p/948659#M371151</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;This is a typo...&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In the line you comment out, I want the N to indicate if any seizure date comes before the first stroke dates (ischemic or hemorrhagic) if this is true then seizure is a post_stroke (n=yes) but if seizure date DOES NOT comes after either stroke dates then the post_stroke (n=no).&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Oct 2024 20:19:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-array-and-calculate-date-variable/m-p/948659#M371151</guid>
      <dc:creator>CathyVI</dc:creator>
      <dc:date>2024-10-22T20:19:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to use array and calculate date variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-array-and-calculate-date-variable/m-p/948668#M371153</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/253321"&gt;@CathyVI&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;This is a typo...&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;In the line you comment out, I want the N to indicate if any seizure date comes before the first stroke dates (ischemic or hemorrhagic) if this is true then seizure is a post_stroke (n=yes) but if seizure date DOES NOT comes after either stroke dates then the post_stroke (n=no).&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If it is&amp;nbsp;&lt;STRONG&gt;before&lt;/STRONG&gt;, you want yes, but if it is&amp;nbsp;&lt;STRONG&gt;not after&lt;/STRONG&gt;, you want no.&lt;/P&gt;
&lt;P&gt;Note: "before" and "not after" indicate the &lt;U&gt;same&lt;/U&gt; time frame in English.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Oct 2024 21:27:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-array-and-calculate-date-variable/m-p/948668#M371153</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2024-10-22T21:27:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to use array and calculate date variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-array-and-calculate-date-variable/m-p/948678#M371158</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/253321"&gt;@CathyVI&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below code populates variable FLG with values that match your variable N in the sample data.&lt;/P&gt;
&lt;P&gt;Please add additional rows/data for use cases where you believe below code won't return what you desire. Given the already ongoing discussion I believe sample data with desired outcome that covers all your cases will get us faster to your desired solution.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
    input ID $ First_Ischemic :date9. First_Hemorrhagic :date9. R_Seizure_1 :date9. R_Seizure_2 :date9. R_Seizure_3 :date9. R_Seizure_4 :date9. n $;
    format First_Ischemic First_Hemorrhagic R_Seizure_1 R_Seizure_2 R_Seizure_3 R_Seizure_4 date9.;
    datalines;
11386 23SEP2004 10FEB2020 . . . 12AUG2015 no
11396 23SEP2004 10FEB2004 . . . 11FEB2020 yes
11427 11SEP2010 09AUG2010 10SEP2010 03FEB2012 . . yes
12666 . 18SEP2006 20JUN2002 . . . no
20485 15JUL2019 . . . 15AUG2009 25JUL2010 no
23434 . 18OCT2002 21JUN2003 . . . yes
32462 13AUG2014 . 12AUG2014 20JUN2002 . . no
34627 01DEC2009 30NOV2009 . 10FEB2010 . . yes
;
run;

proc format;
  value yesno (default=3)
    1='yes'
    0='no'
    other='n/a'
    ;
run;

data want;
  set have;
  length flg 3;
  format flg yesno.;
  flg = max(of R_Seizure_:) &amp;gt; max(First_Ischemic,First_Hemorrhagic); 
run;

proc print data=want;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1729640322070.png" style="width: 821px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/101717i34B58A0291BE8BAB/image-dimensions/821x240?v=v2" width="821" height="240" role="button" title="Patrick_0-1729640322070.png" alt="Patrick_0-1729640322070.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Oct 2024 23:47:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-array-and-calculate-date-variable/m-p/948678#M371158</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-10-22T23:47:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to use array and calculate date variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-array-and-calculate-date-variable/m-p/948680#M371159</link>
      <description>&lt;P&gt;An array does not really help with this problem since there is no need to loop.&lt;/P&gt;
&lt;P&gt;Use the OF keyword to pass use a variable list when calling a function that takes an flexible number of arguments.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First let's add a few more examples to handle the missing values issues.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input ID $6. First_Ischemic  First_Hemorrhagic R_Seizure_1-R_Seizure_3 ;
  format First_Ischemic  First_Hemorrhagic  R_Seizure_1-R_Seizure_3 date9.;
  informat First_Ischemic  First_Hemorrhagic  R_Seizure_1-R_Seizure_3 date.;
datalines;
011386 23SEP2004 10FEB2020         .         . 12AUG2015
011396 23SEP2004 10FEB2004         .         . 11FEB2020 
011427 11SEP2010 09AUG2010 10SEP2010 03FEB2012         . 
012666         . 18SEP2006 20JUN2002         .         .
020485 15JUL2019         .         . 15AUG2009 25JUL2010
023434         . 18OCT2002 21JUN2003         .         .
032462 13AUG2014         . 12AUG2014 20JUN2002         .
034627 01DEC2009 30NOV2009         . 10FEB2010         .
555555 01JAN2024         .         .         .         .
666666         .         . 01JAN2024         .         .
777777         .         .         .         .         .
888888 01JAN2024         . 01JAN2023 01MAY2024         .
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now let's create some flags to indicate if there are any seizure dates or stroke dates by using the N() function.&amp;nbsp; We can then use MIN and/or MAX to check if ANY of the seizure dates were before the first stroke.&amp;nbsp; Or if&amp;nbsp; or any seizure dates where after the first stroke. You could also test if ALL of the seizure dates are after the first stroke.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
 value ynu 0='No' 1='Yes' .='N/A';
run;

data want;
  set have;
  Any_Seizure = 0&amp;lt;N(of R_Seizure_1-R_Seizure_3);
  Any_Stroke = 0&amp;lt;N(of First_Ischemic  First_Hemorrhagic);
  if Any_seizure and Any_Stroke then do;
     Any_pre = min(of R_Seizure_1-R_Seizure_3) &amp;lt; min(of First_Ischemic  First_Hemorrhagic);
     All_pre = max(of R_Seizure_1-R_Seizure_3) &amp;lt; min(of First_Ischemic  First_Hemorrhagic);
     Any_post = max(of R_Seizure_1-R_Seizure_3) &amp;gt; min(of First_Ischemic  First_Hemorrhagic);
     All_post = min(of R_Seizure_1-R_Seizure_3) &amp;gt; min(of First_Ischemic  First_Hemorrhagic);
  end;
  format any_: all_: ynu.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_0-1729647980939.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/101719iA69C0A884E223B32/image-size/large?v=v2&amp;amp;px=999" role="button" title="Tom_0-1729647980939.png" alt="Tom_0-1729647980939.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Oct 2024 01:46:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-array-and-calculate-date-variable/m-p/948680#M371159</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-10-23T01:46:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to use array and calculate date variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-array-and-calculate-date-variable/m-p/948713#M371169</link>
      <description>&lt;P&gt;Depending on whether or not you &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/253321"&gt;@CathyVI&lt;/a&gt; are correct or &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt; is correct, you want some variation of this command (note: no arrays needed)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if max (of&amp;nbsp;r_seizure1-r_seizure4)&amp;nbsp;&amp;lt; min&amp;nbsp;(first_ischemic,first_herorrhagic)&amp;nbsp;then&amp;nbsp;n=1;&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;If that's not exactly what you want, then your homework assignment is to figure out what variation of the above code is correct for you. &lt;/P&gt;</description>
      <pubDate>Wed, 23 Oct 2024 10:54:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-array-and-calculate-date-variable/m-p/948713#M371169</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-10-23T10:54:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to use array and calculate date variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-array-and-calculate-date-variable/m-p/948807#M371193</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;THANK YOU ALL!!! I appreciate all your comments and guidance. All of you are right. If I could pick multiple solutions I would i pick all but SAS only allows one solution so I just pick the one I found simple to understand - knowing that i continue to learn SAS, am not an expert yet. Thank you all again.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Oct 2024 19:25:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-array-and-calculate-date-variable/m-p/948807#M371193</guid>
      <dc:creator>CathyVI</dc:creator>
      <dc:date>2024-10-23T19:25:06Z</dc:date>
    </item>
  </channel>
</rss>

