<?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: Apply floors to the dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Apply-floors-to-the-dataset/m-p/928299#M365230</link>
    <description>&lt;P&gt;So it does not matter what COL2 has already?&amp;nbsp; Then why did you include it?&lt;/P&gt;
&lt;P&gt;What do you want to do with values from 3 to 4?&amp;nbsp; Or are you saying COL1 can only contain integers?&lt;/P&gt;
&lt;P&gt;What do you want to do with missing values?&lt;/P&gt;
&lt;P&gt;This code will convert anything less than 4 (including missing values) into 3 and everything else to 4.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input Col1 Expect;
datalines;
1 3
2 3
3 3
4 4
5 4
6 4
7 4
;

data want;
  set have;
  if col1 &amp;lt; 4 then col2=3;
  else col2=4;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result&lt;/P&gt;
&lt;PRE&gt;Obs    Col1    Expect    col2

 1       1        3        3
 2       2        3        3
 3       3        3        3
 4       4        4        4
 5       5        4        4
 6       6        4        4
 7       7        4        4
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 14 May 2024 15:16:43 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2024-05-14T15:16:43Z</dc:date>
    <item>
      <title>Apply floors to the dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apply-floors-to-the-dataset/m-p/928265#M365215</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to apply two floors to the existing dataset below (Col1 values are sorted):&lt;/P&gt;&lt;P&gt;1) For any values in Col1 &lt;span class="lia-unicode-emoji" title=":red_heart:"&gt;❤️&lt;/span&gt; replace their values in Col2 with that for Col1 =3;&lt;/P&gt;&lt;P&gt;1) For any values in Col1 &amp;gt;4 replace their values in Col2 with that for Col1 =4;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;input Col1 Col2;&lt;BR /&gt;datalines;&lt;BR /&gt;1 1&lt;BR /&gt;2 2&lt;BR /&gt;3 3&lt;BR /&gt;4 4&lt;BR /&gt;5 3&lt;BR /&gt;6 2&lt;/P&gt;&lt;P&gt;7 1&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;Col1 Col2;&lt;BR /&gt;1 3&lt;BR /&gt;2 3&lt;BR /&gt;3 3&lt;BR /&gt;4 4&lt;BR /&gt;5 4&lt;BR /&gt;6 4&lt;/P&gt;&lt;P&gt;7 4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 May 2024 11:38:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apply-floors-to-the-dataset/m-p/928265#M365215</guid>
      <dc:creator>fwu811</dc:creator>
      <dc:date>2024-05-14T11:38:41Z</dc:date>
    </item>
    <item>
      <title>Re: Apply floors to the dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apply-floors-to-the-dataset/m-p/928269#M365217</link>
      <description>1) For any values in Col1 &lt;span class="lia-unicode-emoji" title=":red_heart:"&gt;❤️&lt;/span&gt; replace their values in Col2 with that for Col1 =3;</description>
      <pubDate>Tue, 14 May 2024 12:08:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apply-floors-to-the-dataset/m-p/928269#M365217</guid>
      <dc:creator>fwu811</dc:creator>
      <dc:date>2024-05-14T12:08:20Z</dc:date>
    </item>
    <item>
      <title>Re: Apply floors to the dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apply-floors-to-the-dataset/m-p/928270#M365218</link>
      <description>Updated:&lt;BR /&gt;1) For any values in Col1 less than 3 replace their values in Col2 with that for Col1 =3;</description>
      <pubDate>Tue, 14 May 2024 12:09:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apply-floors-to-the-dataset/m-p/928270#M365218</guid>
      <dc:creator>fwu811</dc:creator>
      <dc:date>2024-05-14T12:09:13Z</dc:date>
    </item>
    <item>
      <title>Re: Apply floors to the dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apply-floors-to-the-dataset/m-p/928275#M365220</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/460804"&gt;@fwu811&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
if _n_=1 then do until(last);
  set have(where=(col1 in (3,4))) end=last;
  array v[3:4] _temporary_;
  v[col1]=col2;
end;
set have;
if .z&amp;lt;col1&amp;lt;3 then col2=v[3];
else if col1&amp;gt;4 then col2=v[4];
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that values &lt;FONT face="trebuchet ms,geneva" size="3"&gt;&amp;lt;&lt;/FONT&gt;3 include missing values. If you really want to treat observations with missing &lt;FONT face="courier new,courier"&gt;Col1&lt;/FONT&gt; the same way as those with &lt;FONT face="courier new,courier"&gt;Col1=2&lt;/FONT&gt;, &lt;FONT face="courier new,courier"&gt;Col1=&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;1&lt;/FONT&gt;, etc., just delete the "&lt;FONT face="courier new,courier"&gt;.z&amp;lt;&lt;/FONT&gt;" part of the IF condition above.&lt;/P&gt;</description>
      <pubDate>Tue, 14 May 2024 12:43:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apply-floors-to-the-dataset/m-p/928275#M365220</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2024-05-14T12:43:19Z</dc:date>
    </item>
    <item>
      <title>Re: Apply floors to the dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apply-floors-to-the-dataset/m-p/928299#M365230</link>
      <description>&lt;P&gt;So it does not matter what COL2 has already?&amp;nbsp; Then why did you include it?&lt;/P&gt;
&lt;P&gt;What do you want to do with values from 3 to 4?&amp;nbsp; Or are you saying COL1 can only contain integers?&lt;/P&gt;
&lt;P&gt;What do you want to do with missing values?&lt;/P&gt;
&lt;P&gt;This code will convert anything less than 4 (including missing values) into 3 and everything else to 4.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input Col1 Expect;
datalines;
1 3
2 3
3 3
4 4
5 4
6 4
7 4
;

data want;
  set have;
  if col1 &amp;lt; 4 then col2=3;
  else col2=4;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result&lt;/P&gt;
&lt;PRE&gt;Obs    Col1    Expect    col2

 1       1        3        3
 2       2        3        3
 3       3        3        3
 4       4        4        4
 5       5        4        4
 6       6        4        4
 7       7        4        4
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 May 2024 15:16:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apply-floors-to-the-dataset/m-p/928299#M365230</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-05-14T15:16:43Z</dc:date>
    </item>
    <item>
      <title>Re: Apply floors to the dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apply-floors-to-the-dataset/m-p/928450#M365289</link>
      <description>The values in Col1 for applying a floor is set to by the user, and the floored value to Col2 is determined by the the corresponding Col2 for the Col1 value.</description>
      <pubDate>Wed, 15 May 2024 09:39:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apply-floors-to-the-dataset/m-p/928450#M365289</guid>
      <dc:creator>fwu811</dc:creator>
      <dc:date>2024-05-15T09:39:01Z</dc:date>
    </item>
  </channel>
</rss>

