<?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 Output depending on a CASE WHEN condition in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Output-depending-on-a-CASE-WHEN-condition/m-p/843953#M333647</link>
    <description>&lt;P&gt;Hi Team,&lt;/P&gt;&lt;P&gt;&amp;nbsp;Looking to satisfy the below condition and get an output accordingly. Please see below.&amp;nbsp;&lt;/P&gt;&lt;P&gt;data data.my_data;&lt;/P&gt;&lt;P&gt;input my_number;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;80.000000001&lt;/P&gt;&lt;P&gt;1000.01&lt;/P&gt;&lt;P&gt;879.987&lt;/P&gt;&lt;P&gt;70.987656&lt;/P&gt;&lt;P&gt;13.097360083&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;Run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;New my_number1 column should be satisfying the below conditions:&lt;/P&gt;&lt;P&gt;1. my_number1 should be rounded to 2 decimal places&lt;/P&gt;&lt;P&gt;2. my_number1 should be rounded to 2nd decimal if the my_number has any non zero value in the 3rd to 9th decimal places. Example: If my_number is 80.000000001, round up to 80.01&lt;/P&gt;&lt;P&gt;3. If my_number is greater than 999.99 then my_number1 is set to 999.99&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 12 Nov 2022 21:00:26 GMT</pubDate>
    <dc:creator>Newsas2023</dc:creator>
    <dc:date>2022-11-12T21:00:26Z</dc:date>
    <item>
      <title>Output depending on a CASE WHEN condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-depending-on-a-CASE-WHEN-condition/m-p/843953#M333647</link>
      <description>&lt;P&gt;Hi Team,&lt;/P&gt;&lt;P&gt;&amp;nbsp;Looking to satisfy the below condition and get an output accordingly. Please see below.&amp;nbsp;&lt;/P&gt;&lt;P&gt;data data.my_data;&lt;/P&gt;&lt;P&gt;input my_number;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;80.000000001&lt;/P&gt;&lt;P&gt;1000.01&lt;/P&gt;&lt;P&gt;879.987&lt;/P&gt;&lt;P&gt;70.987656&lt;/P&gt;&lt;P&gt;13.097360083&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;Run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;New my_number1 column should be satisfying the below conditions:&lt;/P&gt;&lt;P&gt;1. my_number1 should be rounded to 2 decimal places&lt;/P&gt;&lt;P&gt;2. my_number1 should be rounded to 2nd decimal if the my_number has any non zero value in the 3rd to 9th decimal places. Example: If my_number is 80.000000001, round up to 80.01&lt;/P&gt;&lt;P&gt;3. If my_number is greater than 999.99 then my_number1 is set to 999.99&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 12 Nov 2022 21:00:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-depending-on-a-CASE-WHEN-condition/m-p/843953#M333647</guid>
      <dc:creator>Newsas2023</dc:creator>
      <dc:date>2022-11-12T21:00:26Z</dc:date>
    </item>
    <item>
      <title>Re: Output depending on a CASE WHEN condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-depending-on-a-CASE-WHEN-condition/m-p/843954#M333648</link>
      <description>&lt;P&gt;Please show us what you have tried so far.&lt;/P&gt;</description>
      <pubDate>Sat, 12 Nov 2022 21:41:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-depending-on-a-CASE-WHEN-condition/m-p/843954#M333648</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-11-12T21:41:20Z</dc:date>
    </item>
    <item>
      <title>Re: Output depending on a CASE WHEN condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-depending-on-a-CASE-WHEN-condition/m-p/843961#M333652</link>
      <description>&lt;P&gt;Not sure what type of rounding that is. Does below return the desired result? If not then please provide the desired result based on your sample data. What should happen if there is a non-zero value on the 10th or later decimal?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input my_number;
  datalines;
80.000000001
1000.01
879.987
70.987656
13.097360083
.
;

data want;
  set have;
  format my_number derived_num 16.9;
  if not missing(my_number) then
    derived_num=min(999.99,ceilz(my_number*100)/100);
run;

proc print data=want;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1668295508833.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/77239iA0828D31D3090175/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1668295508833.png" alt="Patrick_0-1668295508833.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>Sat, 12 Nov 2022 23:32:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-depending-on-a-CASE-WHEN-condition/m-p/843961#M333652</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2022-11-12T23:32:53Z</dc:date>
    </item>
    <item>
      <title>Re: Output depending on a CASE WHEN condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-depending-on-a-CASE-WHEN-condition/m-p/843964#M333653</link>
      <description>&lt;BR /&gt;Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;, I was trying the below, but haven't succeeded. Trying different combinations like splitting the numbers and then performing a check&lt;BR /&gt;&lt;BR /&gt;PROC SQL;&lt;BR /&gt;CREATE TABLE data.new_dataset AS&lt;BR /&gt;SELECT t1.*,&lt;BR /&gt;&lt;BR /&gt;CASE WHEN substr(scan(put(my_number,best32.),2,"."),1,1) = '0' AND ....&lt;BR /&gt;THEN ...&lt;BR /&gt;&lt;BR /&gt;WHEN LTV_New &amp;gt; 999.9&lt;BR /&gt;THEN 999.9&lt;BR /&gt;&lt;BR /&gt;ELSE round(LTV_New, 0.01)&lt;BR /&gt;END AS new_num&lt;BR /&gt;&lt;BR /&gt;FROM data.my_data t1;&lt;BR /&gt;QUIT;</description>
      <pubDate>Sun, 13 Nov 2022 00:20:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-depending-on-a-CASE-WHEN-condition/m-p/843964#M333653</guid>
      <dc:creator>Newsas2023</dc:creator>
      <dc:date>2022-11-13T00:20:58Z</dc:date>
    </item>
    <item>
      <title>Re: Output depending on a CASE WHEN condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-depending-on-a-CASE-WHEN-condition/m-p/843965#M333654</link>
      <description>&lt;P&gt;Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;, this is great. Thank you very much for this. Will try and incorporate this into my code.&lt;BR /&gt;Would it be possible to round the "derived_num" column to 2 decimal places?&lt;BR /&gt;Example: if I use the round function on column "derived_num" to give me 2 decimal places after the decimal point, then Obs 5 would be 13.1, is it possible to get 13.10?&lt;/P&gt;</description>
      <pubDate>Sun, 13 Nov 2022 00:29:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-depending-on-a-CASE-WHEN-condition/m-p/843965#M333654</guid>
      <dc:creator>Newsas2023</dc:creator>
      <dc:date>2022-11-13T00:29:51Z</dc:date>
    </item>
    <item>
      <title>Re: Output depending on a CASE WHEN condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-depending-on-a-CASE-WHEN-condition/m-p/843966#M333655</link>
      <description>&lt;P&gt;There is no difference between 13.1 and 13.10.&amp;nbsp; They are the same number.&lt;/P&gt;
&lt;P&gt;If you want the value to always be displayed using 2 decimal places then attach a format that 2 for the number of decimal places.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;format derived_num 8.2 ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 13 Nov 2022 00:36:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-depending-on-a-CASE-WHEN-condition/m-p/843966#M333655</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-11-13T00:36:45Z</dc:date>
    </item>
    <item>
      <title>Re: Output depending on a CASE WHEN condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-depending-on-a-CASE-WHEN-condition/m-p/843967#M333656</link>
      <description>Thanks a lot, &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;, will try this out. True, they are the same number, this was from an output requirement standpoint. Appreciate it!</description>
      <pubDate>Sun, 13 Nov 2022 00:44:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-depending-on-a-CASE-WHEN-condition/m-p/843967#M333656</guid>
      <dc:creator>Newsas2023</dc:creator>
      <dc:date>2022-11-13T00:44:44Z</dc:date>
    </item>
  </channel>
</rss>

