<?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: change values in Score1-Score12 aftewr first Score that equal 11 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/change-values-in-Score1-Score12-aftewr-first-Score-that-equal-11/m-p/629887#M186399</link>
    <description>&lt;P&gt;And yet another:&lt;/P&gt;
&lt;PRE&gt;data want;
   set have;
   array scores score1-score12;

   if 0&amp;lt; whichn(11, of scores(*)) &amp;lt; 11 then do i=(whichn(11, of scores(*))+1) to dim(scores);
      scores[i]= .;
   end;
   drop i;
run;&lt;/PRE&gt;
&lt;P&gt;The WHICHN, and WHICHC for character varaibles, will return the position that the value of the first parameter, the 11 in this case, is first found in left&amp;nbsp;to right order&amp;nbsp;in the list of following values, here using the array notation. The order of variables assigned to the array would be the order evaluated. It returns 0 if the value is not found.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You didn't really explicitly say what might happen if the LAST value is 11. I am assuming that you do nothing.&lt;/P&gt;</description>
    <pubDate>Thu, 05 Mar 2020 17:31:46 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2020-03-05T17:31:46Z</dc:date>
    <item>
      <title>change values in Score1-Score12 aftewr first Score that equal 11</title>
      <link>https://communities.sas.com/t5/SAS-Programming/change-values-in-Score1-Score12-aftewr-first-Score-that-equal-11/m-p/629753#M186317</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I have a raw data table that contain about each customer information about score in follow up period (12 months).&lt;/P&gt;
&lt;P&gt;score 11 is defined as a failure.&lt;/P&gt;
&lt;P&gt;I want to change the values in fields Score1-Score12 by following rule:&lt;/P&gt;
&lt;P&gt;IF one of the scores get value 11 then all scores after will have null value.&lt;/P&gt;
&lt;P&gt;For example:&lt;/P&gt;
&lt;P&gt;For ID&amp;nbsp;11111111 the first score that equal 11 is Score 4&amp;nbsp; so Score5-Score12 will get null value&lt;/P&gt;
&lt;P&gt;For ID 22222222&amp;nbsp; &amp;nbsp;there is no score with value 11 so there are no changes in values of score1-score12&lt;/P&gt;
&lt;P&gt;For ID 33333333 the first score that equal 11 is Score 1&amp;nbsp; so Score2-Score12 will get null value&lt;/P&gt;
&lt;P&gt;For ID 44444444 &amp;nbsp; there is no score with value 11 so there are no changes in values of score1-score12&lt;/P&gt;</description>
      <pubDate>Thu, 05 Mar 2020 10:03:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/change-values-in-Score1-Score12-aftewr-first-Score-that-equal-11/m-p/629753#M186317</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2020-03-05T10:03:11Z</dc:date>
    </item>
    <item>
      <title>Re: change values in Score1-Score12 aftewr first Score that equal 11</title>
      <link>https://communities.sas.com/t5/SAS-Programming/change-values-in-Score1-Score12-aftewr-first-Score-that-equal-11/m-p/629756#M186319</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is an attempt to achieve this. Does it meets your expectations?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	input ID score1-score12;
	datalines;
11111111 1 1 1 11 1 1 1 1 1 1 1 1
22222222 1 1 1 1 1 1 1 1 1 1 1 1
33333333 11 1 1 1 1 1 1 1 1 1 1 1 
44444444 1 1 1 1 1 1 1 1 1 1 1 1
;
run;

data want;
	set have;
	array _score(*) score1-score12;
	do i=1 to dim(_score);
		if _score(i) = 11 then flag = i+1;
	end;
	if flag=. then flag = (dim(_score)+1);
	do j=flag to dim(_score);
		_score(j) = .;
	end;
	drop i j flag;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture d’écran 2020-03-05 à 11.13.34.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/36615i38EDEC6E4F3914EB/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture d’écran 2020-03-05 à 11.13.34.png" alt="Capture d’écran 2020-03-05 à 11.13.34.png" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Mar 2020 10:14:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/change-values-in-Score1-Score12-aftewr-first-Score-that-equal-11/m-p/629756#M186319</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-03-05T10:14:12Z</dc:date>
    </item>
    <item>
      <title>Re: change values in Score1-Score12 aftewr first Score that equal 11</title>
      <link>https://communities.sas.com/t5/SAS-Programming/change-values-in-Score1-Score12-aftewr-first-Score-that-equal-11/m-p/629766#M186325</link>
      <description>&lt;P&gt;or with just one loop&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data wantB;
   set have;

   array scores score1-score12;

   kill = 0;

   do i = 1 to dim(scores);
      if kill then scores[i] = .;
      if not kill and scores[i] = 11 then kill = 1;
   end;

   drop i kill;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;thanks for providing data &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292097"&gt;@ed_sas_member&lt;/a&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Mar 2020 10:41:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/change-values-in-Score1-Score12-aftewr-first-Score-that-equal-11/m-p/629766#M186325</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2020-03-05T10:41:30Z</dc:date>
    </item>
    <item>
      <title>Re: change values in Score1-Score12 aftewr first Score that equal 11</title>
      <link>https://communities.sas.com/t5/SAS-Programming/change-values-in-Score1-Score12-aftewr-first-Score-that-equal-11/m-p/629887#M186399</link>
      <description>&lt;P&gt;And yet another:&lt;/P&gt;
&lt;PRE&gt;data want;
   set have;
   array scores score1-score12;

   if 0&amp;lt; whichn(11, of scores(*)) &amp;lt; 11 then do i=(whichn(11, of scores(*))+1) to dim(scores);
      scores[i]= .;
   end;
   drop i;
run;&lt;/PRE&gt;
&lt;P&gt;The WHICHN, and WHICHC for character varaibles, will return the position that the value of the first parameter, the 11 in this case, is first found in left&amp;nbsp;to right order&amp;nbsp;in the list of following values, here using the array notation. The order of variables assigned to the array would be the order evaluated. It returns 0 if the value is not found.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You didn't really explicitly say what might happen if the LAST value is 11. I am assuming that you do nothing.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Mar 2020 17:31:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/change-values-in-Score1-Score12-aftewr-first-Score-that-equal-11/m-p/629887#M186399</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-03-05T17:31:46Z</dc:date>
    </item>
  </channel>
</rss>

