<?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 assign values based on condition in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-assign-values-based-on-condition/m-p/502250#M134050</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/62004"&gt;@vraj1&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are at least two possible interpretations of your criteria and hence different solutions:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;The "first 2 days" are days 1 and 2 (according to variable DAY), the "next 2 days" are days 3 and 4 and so on.&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set test(drop=exd);
if period='A' then do;
       if ext='pine' then exd=2*min(int((day+1)/2),3);
  else if ext='ozi'  then exd=5*min(int((day+1)/2),3);
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/LI&gt;
&lt;LI&gt;The&amp;nbsp;&lt;SPAN&gt;&lt;SPAN&gt;"first 2 days" with EXT='pine' correspond to the first two observations with PERIOD='A' and EXT='pine' within an ID regardless of DAY (but assuming chronological sort order), etc.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set test(drop=exd);
by id day;
if first.id then call missing(_cp, _co);
if period='A' then do;
       if ext='pine' then do; _cp+1; exd=2*min(int((_cp+1)/2),3); end;
  else if ext='ozi'  then do; _co+1; exd=5*min(int((_co+1)/2),3); end;
end;                                     
drop _:;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/LI&gt;
&lt;/OL&gt;</description>
    <pubDate>Sun, 07 Oct 2018 12:16:24 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2018-10-07T12:16:24Z</dc:date>
    <item>
      <title>how to assign values based on condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-assign-values-based-on-condition/m-p/502225#M134039</link>
      <description>&lt;P&gt;i want to assign values for EXD based on the below condition&lt;/P&gt;
&lt;P&gt;EXT is "pine", EXD should be assigned by value 2 for the first 2 days, value 4 for the next 2 days and value 6 for the remaining Period A. If EXT is "ozi", EXD &lt;SPAN&gt;should&amp;nbsp;&lt;/SPAN&gt;be assigned by value 5 for the first 2 days, value 10 for the next 2 days and value 15 for the remaining Period A.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Attached test data. can any one suggest how to do it.?&lt;/P&gt;</description>
      <pubDate>Sun, 07 Oct 2018 07:38:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-assign-values-based-on-condition/m-p/502225#M134039</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2018-10-07T07:38:09Z</dc:date>
    </item>
    <item>
      <title>Re: how to assign values based on condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-assign-values-based-on-condition/m-p/502250#M134050</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/62004"&gt;@vraj1&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are at least two possible interpretations of your criteria and hence different solutions:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;The "first 2 days" are days 1 and 2 (according to variable DAY), the "next 2 days" are days 3 and 4 and so on.&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set test(drop=exd);
if period='A' then do;
       if ext='pine' then exd=2*min(int((day+1)/2),3);
  else if ext='ozi'  then exd=5*min(int((day+1)/2),3);
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/LI&gt;
&lt;LI&gt;The&amp;nbsp;&lt;SPAN&gt;&lt;SPAN&gt;"first 2 days" with EXT='pine' correspond to the first two observations with PERIOD='A' and EXT='pine' within an ID regardless of DAY (but assuming chronological sort order), etc.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set test(drop=exd);
by id day;
if first.id then call missing(_cp, _co);
if period='A' then do;
       if ext='pine' then do; _cp+1; exd=2*min(int((_cp+1)/2),3); end;
  else if ext='ozi'  then do; _co+1; exd=5*min(int((_co+1)/2),3); end;
end;                                     
drop _:;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Sun, 07 Oct 2018 12:16:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-assign-values-based-on-condition/m-p/502250#M134050</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-10-07T12:16:24Z</dc:date>
    </item>
  </channel>
</rss>

