<?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: conditional do loop to iteratively update assignment of flag per subject based on priority ranki in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/conditional-do-loop-to-iteratively-update-assignment-of-flag-per/m-p/839727#M331999</link>
    <description>&lt;P&gt;Perfect thanks a lot!&lt;/P&gt;</description>
    <pubDate>Thu, 20 Oct 2022 17:01:31 GMT</pubDate>
    <dc:creator>smackerz1988</dc:creator>
    <dc:date>2022-10-20T17:01:31Z</dc:date>
    <item>
      <title>conditional do loop to iteratively update assignment of flag per subject based on priority ranking</title>
      <link>https://communities.sas.com/t5/SAS-Programming/conditional-do-loop-to-iteratively-update-assignment-of-flag-per/m-p/839639#M331973</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have to derive aval based on conditional strategies.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"in the following order of priority: &lt;BR /&gt;1) Check "SWREL". If aval eq 1: Composite strategy 2 using "EASITOTA" as the source score &lt;BR /&gt;&lt;EM&gt;if swrel = 1&amp;nbsp; then flg currently will be 'Composite Strategy 2'.&amp;nbsp; if swrel = 0 for all records per subject flag will be blank at this stage&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;2) Check "RTT1L28D” and “TCM2”. If aval eq 1: Composite strategy 1 using "EASITOTA" as the source score&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;if either tcm2 or rtt1l28 = 1 along with swrel = 1 then flg will change from "Composite Strategy 2 " to&amp;nbsp; "Composite Strategy 1" .&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt; If swrel,rtt1l28,tcm2 all = 0&amp;nbsp;for all records per subject then&amp;nbsp;flag will be blank at this stage&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;2) Check "SWNREL" aval eq 1: While-on-Treatment strategy.&lt;/P&gt;
&lt;P&gt;if&amp;nbsp;&lt;EM&gt;swnrel = 1&amp;nbsp; &amp;nbsp;and tcm2 or rtt1l28= 1 then flg&amp;nbsp; will be 'While-on-Treatment'.&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;3) Apply treatment policy strategy – use data as collected in “EASITOTA”"&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;If swrel,rtt1l28,tcm2,swnrel all = 0&amp;nbsp;for all records per subject then&amp;nbsp;flag will be 'treatment policy'&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Programming logic&lt;BR /&gt;"1)If AVAL = 1 for&amp;nbsp; "SWREL" , apply Composite strategy 2 using "EASITOTA" aval. 2) If AVAL equals 1 on either record where&amp;nbsp; "RTT1L28D" or "T2CM", apply Composite strategy 1 using "EASITOTA" aval. 3) If SWNREL equals 1 on the record,&amp;nbsp; apply While-on-Treatment strategy. 4) Apply Treatment Policy strategy using "EASITOTA" aval."&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the data in it's merged form with all relevant variables. For context the aval for SWREL, SWNREL, TCM2&amp;nbsp; and RTT1L28 represent intercurrent events and the score (AVAL)&amp;nbsp; was transposed to the EASITOTA&amp;nbsp; dataset and a value of 1 indicates an intercurrent event occurred and a value of 0 indicates no intercurrent event.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input  PARAMCD $ SUBJID $ AVISITN :8. ADT :$9. AVAL :8. RTT1L28D :8. T2CM :8. SWREL :8.  SWNREL :8.;
infile datalines dlm = '|';
datalines;
EASITOTA|1001|20|27APR2022|13.4|0|0|0|0
EASITOTA|1001|30|11MAY2022|13.4|0|0|0|0
EASITOTA|1001|40|26MAY2022|13.4|0|0|0|0
EASITOTA|1001|50|22JUN2022|13.4|0|0|0|0
EASITOTA|1001|60|20JUL2022|13.4|0|0|0|0
EASITOTA|1001|70|31AUG2022|13.4|0|0|0|0
EASITOTA|1002|20|27APR2022|16.4|0|0|0|0
EASITOTA|1002|30|11MAY2022|16.4|0|0|0|0
EASITOTA|1002|40|25MAY2022|16.4|1|0|0|0
EASITOTA|1002|50|22JUN2022|16.4|1|0|0|0
EASITOTA|1002|60|20JUL2022|16.4|1|0|0|0
EASITOTA|1002|70|22AUG2022|16.4|1|0|0|0
EASITOTA|1003|20|07JUN2022|15.8|0|0|1|0
EASITOTA|1003|20|21JUN2022|15.8|1|0|1|0
EASITOTA|1003|30|05JUL2022|15.8|1|0|1|0
EASITOTA|1003|40|02AUG2022|15.8|0|0|1|0
EASITOTA|1003|50|30AUG2022|15.8|0|0|1|0
EASITOTA|1003|60|27SEP2022|15.8|0|0|1|0
EASITOTA|1003|70|25OCT2022|15.8|0|0|1|0

;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Basically I would like to create a flag that assigns the correct strategy to all records per subject so I can further go on to derive aval (based on these strategies below). I was thinking that a conditional dow loop may work here but if there is a simpler approach I would really appreciate it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="smackerz1988_0-1666276222443.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/76392i4AC1B90F1CF8472C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="smackerz1988_0-1666276222443.png" alt="smackerz1988_0-1666276222443.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>Thu, 20 Oct 2022 15:39:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/conditional-do-loop-to-iteratively-update-assignment-of-flag-per/m-p/839639#M331973</guid>
      <dc:creator>smackerz1988</dc:creator>
      <dc:date>2022-10-20T15:39:14Z</dc:date>
    </item>
    <item>
      <title>Re: conditional do loop to iteratively update assignment of flag per subject based on priority ranki</title>
      <link>https://communities.sas.com/t5/SAS-Programming/conditional-do-loop-to-iteratively-update-assignment-of-flag-per/m-p/839681#M331986</link>
      <description>&lt;P&gt;I have to say that I cannot follow what is intended by any of priorities 1 through 4.&lt;/P&gt;
&lt;P&gt;Examples of interpretation:&lt;/P&gt;
&lt;P&gt;What are we checking SWREL for what/how and what indication that it has been checked (since this step is apparently needed for the second)? When checking "RTT1L28D” and “TCM2” is that each variable individually or combinations of the two, for what and how to indicate "checked"?&lt;/P&gt;
&lt;P&gt;What is a "Composite Strategy"? What variables are involved and how?&lt;/P&gt;
&lt;P&gt;What is a "source score"? How is it used? what variables?&lt;/P&gt;
&lt;P&gt;What is an "intercurrent event"? Variables and values needed to tell what one is?&lt;/P&gt;
&lt;P&gt;What is "While-on treatment strategy"? Variables and values to use?&lt;/P&gt;
&lt;P&gt;How to apply a "treatment policy strategy"?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And what exactly does "if no changes to data in step 1" mean? For specific records? Specific value combinations of some variables? The entire data set?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may have to talk us through some specific examples. These priorities are a pretty good example of very specific to one field jargon and need translation to anyone working outside of that field and possibly your organization. So clear definitions and expected results at each step are needed.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2022 14:40:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/conditional-do-loop-to-iteratively-update-assignment-of-flag-per/m-p/839681#M331986</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-10-20T14:40:16Z</dc:date>
    </item>
    <item>
      <title>Re: conditional do loop to iteratively update assignment of flag per subject based on priority ranki</title>
      <link>https://communities.sas.com/t5/SAS-Programming/conditional-do-loop-to-iteratively-update-assignment-of-flag-per/m-p/839691#M331988</link>
      <description>&lt;P&gt;What are we checking SWREL for what/how and what indication that it has been checked (since this step is apparently needed for the second)?&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;SWREL is an intercurrent event and a value of 1 represents it occured and 0 it didn't&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When checking "RTT1L28D” and “TCM2” is that each variable individually or combinations of the two, for what and how to indicate "checked"?&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;that either has a value of 1 or 0&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is a "Composite Strategy"? What variables are involved and how?&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Not needed. It is what I'll be using to derive aval but would like a flag to indicate which strategy per subject I use based on the iterative ranking process&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is a "source score"? How is it used? what variables?&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;synonym for AVAL column&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;What is an "intercurrent event"? Variables and values needed to tell what one is?&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Updated post to give as much information as needed&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is "While-on treatment strategy"? Variables and values to use?&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;same idea as composite strategy. will be a term for the flag value&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How to apply a "treatment policy strategy"?&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;same idea as composite strategy. will be a term for the flag value&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And what exactly does "if no changes to data in step 1" mean? For specific records? Specific value combinations of some variables? The entire data set?&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;All records per subject&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2022 15:19:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/conditional-do-loop-to-iteratively-update-assignment-of-flag-per/m-p/839691#M331988</guid>
      <dc:creator>smackerz1988</dc:creator>
      <dc:date>2022-10-20T15:19:01Z</dc:date>
    </item>
    <item>
      <title>Re: conditional do loop to iteratively update assignment of flag per subject based on priority ranki</title>
      <link>https://communities.sas.com/t5/SAS-Programming/conditional-do-loop-to-iteratively-update-assignment-of-flag-per/m-p/839693#M331990</link>
      <description>&lt;P&gt;I've updated the post to make things clearer&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2022 15:17:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/conditional-do-loop-to-iteratively-update-assignment-of-flag-per/m-p/839693#M331990</guid>
      <dc:creator>smackerz1988</dc:creator>
      <dc:date>2022-10-20T15:17:34Z</dc:date>
    </item>
    <item>
      <title>Re: conditional do loop to iteratively update assignment of flag per subject based on priority ranki</title>
      <link>https://communities.sas.com/t5/SAS-Programming/conditional-do-loop-to-iteratively-update-assignment-of-flag-per/m-p/839724#M331997</link>
      <description>&lt;P&gt;Do you mean something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input  PARAMCD $ SUBJID $ AVISITN :8. ADT :$9. AVAL :8. RTT1L28D :8. T2CM :8. SWREL :8.  SWNREL :8.;
infile datalines dlm = '|';
datalines;
EASITOTA|1001|20|27APR2022|13.4|0|0|0|0
EASITOTA|1001|30|11MAY2022|13.4|0|0|0|0
EASITOTA|1001|40|26MAY2022|13.4|0|0|0|0
EASITOTA|1001|50|22JUN2022|13.4|0|0|0|0
EASITOTA|1001|60|20JUL2022|13.4|0|0|0|0
EASITOTA|1001|70|31AUG2022|13.4|0|0|0|0
EASITOTA|1002|20|27APR2022|16.4|0|0|0|0
EASITOTA|1002|30|11MAY2022|16.4|0|0|0|0
EASITOTA|1002|40|25MAY2022|1   |1|0|0|0
EASITOTA|1002|50|22JUN2022|16.4|1|0|0|0
EASITOTA|1002|60|20JUL2022|16.4|1|0|0|0
EASITOTA|1002|70|22AUG2022|16.4|1|0|0|0
EASITOTA|1003|20|07JUN2022|15.8|0|0|1|0
EASITOTA|1003|20|21JUN2022|15.8|1|0|1|0
EASITOTA|1003|30|05JUL2022|15.8|1|0|1|0
EASITOTA|1003|40|02AUG2022|15.8|0|0|1|0
EASITOTA|1003|50|30AUG2022|1   |0|0|1|0
EASITOTA|1003|60|27SEP2022|15.8|0|0|1|0
EASITOTA|1003|70|25OCT2022|15.8|0|0|1|0

;
run;
proc print; run;&lt;BR /&gt;
/*
1) If AVAL = 1 for  "SWREL" , apply Composite strategy 2 using "EASITOTA" aval. 
2) If AVAL equals 1 on either record where  "RTT1L28D" or "T2CM", apply Composite strategy 1 using "EASITOTA" aval. 
3) If SWNREL equals 1 on the record,  apply While-on-Treatment strategy. 
4) Apply Treatment Policy strategy using "EASITOTA" aval.
*/

proc format;
value strategy
1 = "Composite strategy 2"
2 = "Composite strategy 1"
3 = "While-on-Treatment strategy"
4 = "Treatment Policy strategy"
other = "ERROR"
;
run;

data want;

format strategy strategy.;
do _N_ = 1 by 1 until(last.SUBJID);
  set have;
  by SUBJID;
  select;
    when (AVAL = 1 and SWREL) row_st = 1;
    when (AVAL = 1 and (RTT1L28D or T2CM)) row_st = 2;
    when (SWNREL) row_st = 3;
    otherwise row_st = 4;
  end;

  strategy = min(strategy,row_st);
end;


do _N_ = 1 to _N_;
  set have;
  output;
end;

run;
proc print;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2022 16:53:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/conditional-do-loop-to-iteratively-update-assignment-of-flag-per/m-p/839724#M331997</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2022-10-20T16:53:08Z</dc:date>
    </item>
    <item>
      <title>Re: conditional do loop to iteratively update assignment of flag per subject based on priority ranki</title>
      <link>https://communities.sas.com/t5/SAS-Programming/conditional-do-loop-to-iteratively-update-assignment-of-flag-per/m-p/839727#M331999</link>
      <description>&lt;P&gt;Perfect thanks a lot!&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2022 17:01:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/conditional-do-loop-to-iteratively-update-assignment-of-flag-per/m-p/839727#M331999</guid>
      <dc:creator>smackerz1988</dc:creator>
      <dc:date>2022-10-20T17:01:31Z</dc:date>
    </item>
  </channel>
</rss>

