<?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 create a phase variable based on multiple time and measurement variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-phase-variable-based-on-multiple-time-and/m-p/764592#M242191</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/394922"&gt;@mjalvarez&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I get a blank (.) value for phase_1 using this code -&lt;/P&gt;
&lt;P&gt;data want;&lt;BR /&gt;set have;&lt;/P&gt;
&lt;P&gt;array d (*) exam_date: ;&lt;BR /&gt;array m (*) exam_measure: ;&lt;BR /&gt;do i=dim(m) to 1 by -1;&lt;BR /&gt;if m[i] le 5 then do;&lt;BR /&gt;phase_1= d[i];&lt;BR /&gt;leave;&lt;BR /&gt;end;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;And the contents of the data set have is what? As I mentioned my code is untested because you did not provide an actual data set and you need to show which values actually create missing. I did say if none of the measure values are less than or equal to 5 then the phase variable will not be assigned.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since your code above also uses different variable names then were implied by your example data that is something else to look at: the spelling of the variables.&lt;/P&gt;</description>
    <pubDate>Sat, 28 Aug 2021 00:35:00 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2021-08-28T00:35:00Z</dc:date>
    <item>
      <title>How to create a phase variable based on multiple time and measurement variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-phase-variable-based-on-multiple-time-and/m-p/764237#M242046</link>
      <description>&lt;P&gt;I need to create a variable that gives me the "end" time of an event. Specifically, I need to create a "phase 1"&amp;nbsp; variable that is based on the variables measurement 1-4 and datetime 1-4. To do this, I need to extract the datetime associated with the last measurement &amp;lt;= 5.&lt;BR /&gt;&lt;BR /&gt;For&amp;nbsp;example, my phase_1 variable for Obs #2 would be&amp;nbsp;22JAN19:13:33:00.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's an example of what my data look like:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;obs&lt;/TD&gt;&lt;TD&gt;datetime_1&lt;/TD&gt;&lt;TD&gt;measurement_1&lt;/TD&gt;&lt;TD&gt;datetime_2&lt;/TD&gt;&lt;TD&gt;measurement_2&lt;/TD&gt;&lt;TD&gt;datetime_3&lt;/TD&gt;&lt;TD&gt;measurement_3&lt;/TD&gt;&lt;TD&gt;datetime_4&lt;/TD&gt;&lt;TD&gt;measurement_4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;17APR19:22:56:00&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;18APR19:05:05:00&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;18APR19:06:35:00&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;18APR19:07:04:00&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;22JAN19:11:40:00&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;22JAN19:13:33:00&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;22JAN19:15:29:00&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;TD&gt;22JAN19:16:25:00&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;03MAY15:19:37:00&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;04MAY15:04:30:00&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;04MAY15:07:22:00&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;TD&gt;04MAY15:10:53:00&lt;/TD&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;18FEB20:01:14:00&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;20FEB20:03:05:00&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;20FEB20:04:17:00&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;20FEB20:11:00:00&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Thu, 26 Aug 2021 15:11:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-phase-variable-based-on-multiple-time-and/m-p/764237#M242046</guid>
      <dc:creator>mjalvarez</dc:creator>
      <dc:date>2021-08-26T15:11:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a phase variable based on multiple time and measurement variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-phase-variable-based-on-multiple-time-and/m-p/764247#M242050</link>
      <description>&lt;P&gt;Before we go too far into this do you ever have more than 4 grouped variables?&lt;/P&gt;
&lt;P&gt;Are your measure values monotonic (always increasing, or at least not decreasing), the datetimes as well?&lt;/P&gt;
&lt;P&gt;Do have a need for a phase_2 or phase_3? Different boundaries other than 5?&lt;/P&gt;
&lt;P&gt;An approach that works for a single number of variables with one boundary may not be flexible enough to extend to a more complex case.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Untested but this should get you started:&lt;/P&gt;
&lt;PRE&gt;data want;
   set have;
   array d (*) datetime: ;
   array m (*) measure: ;
   do i=dim(m) to 1 by -1;
      if m[i] le 5 then do; 
         phase_1= d[i];
         leave;
      end;
   end;
run;
      &lt;/PRE&gt;
&lt;P&gt;The arrays start at the highest indexed value assuming it corresponds to the latest datetime value. The first value less than or equal 5 pulls the corresponding date time. The LEAVE statement says to quit executing the loop the first time a value meeting the condition is found.&lt;/P&gt;
&lt;P&gt;If none of the values are less than or equal to 5 no value is assigned to phase_1.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Aug 2021 15:33:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-phase-variable-based-on-multiple-time-and/m-p/764247#M242050</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-08-26T15:33:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a phase variable based on multiple time and measurement variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-phase-variable-based-on-multiple-time-and/m-p/764301#M242070</link>
      <description>Thank you for your response and help! To answer your questions -&lt;BR /&gt;&lt;BR /&gt;Yes, I do have more than 4 grouped variables. I have 20 in total.&lt;BR /&gt;&lt;BR /&gt;All measurement and date variables are monotonic, always increasing.&lt;BR /&gt;&lt;BR /&gt;Right now, I don't need a phase_2 or phase_3.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 26 Aug 2021 18:23:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-phase-variable-based-on-multiple-time-and/m-p/764301#M242070</guid>
      <dc:creator>mjalvarez</dc:creator>
      <dc:date>2021-08-26T18:23:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a phase variable based on multiple time and measurement variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-phase-variable-based-on-multiple-time-and/m-p/764551#M242182</link>
      <description>&lt;P&gt;I get a blank (.) value for phase_1 using this code -&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;set have;&lt;/P&gt;&lt;P&gt;array d (*) exam_date: ;&lt;BR /&gt;array m (*) exam_measure: ;&lt;BR /&gt;do i=dim(m) to 1 by -1;&lt;BR /&gt;if m[i] le 5 then do;&lt;BR /&gt;phase_1= d[i];&lt;BR /&gt;leave;&lt;BR /&gt;end;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Aug 2021 19:27:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-phase-variable-based-on-multiple-time-and/m-p/764551#M242182</guid>
      <dc:creator>mjalvarez</dc:creator>
      <dc:date>2021-08-27T19:27:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a phase variable based on multiple time and measurement variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-phase-variable-based-on-multiple-time-and/m-p/764592#M242191</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/394922"&gt;@mjalvarez&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I get a blank (.) value for phase_1 using this code -&lt;/P&gt;
&lt;P&gt;data want;&lt;BR /&gt;set have;&lt;/P&gt;
&lt;P&gt;array d (*) exam_date: ;&lt;BR /&gt;array m (*) exam_measure: ;&lt;BR /&gt;do i=dim(m) to 1 by -1;&lt;BR /&gt;if m[i] le 5 then do;&lt;BR /&gt;phase_1= d[i];&lt;BR /&gt;leave;&lt;BR /&gt;end;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;And the contents of the data set have is what? As I mentioned my code is untested because you did not provide an actual data set and you need to show which values actually create missing. I did say if none of the measure values are less than or equal to 5 then the phase variable will not be assigned.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since your code above also uses different variable names then were implied by your example data that is something else to look at: the spelling of the variables.&lt;/P&gt;</description>
      <pubDate>Sat, 28 Aug 2021 00:35:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-phase-variable-based-on-multiple-time-and/m-p/764592#M242191</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-08-28T00:35:00Z</dc:date>
    </item>
  </channel>
</rss>

