<?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: format based on more than 1 variable in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/format-based-on-more-than-1-variable/m-p/642273#M21858</link>
    <description>&lt;P&gt;&lt;SPAN&gt;Except for the last two categories, you should be able to collapse the logic to:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;WHEN FLOOR(DATDIF(t1.VERTRBGN, t1.DTENDFLG, '30/360')/30) &amp;lt;= 96
THEN 

&lt;FONT color="#FF0000"&gt;ceil(&lt;/FONT&gt;FLOOR(DATDIF(t1.VERTRBGN, t1.DTENDFLG, '30/360')/30) &lt;FONT color="#FF0000"&gt;/ 6) * 6&lt;/FONT&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 23 Apr 2020 15:03:50 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2020-04-23T15:03:50Z</dc:date>
    <item>
      <title>format based on more than 1 variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/format-based-on-more-than-1-variable/m-p/642244#M21856</link>
      <description>&lt;P&gt;dear SAS experts,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;how can I simplify such blocks:&lt;/P&gt;&lt;P&gt;- it's a new varaible based on more than 1 variable and using a formula&lt;/P&gt;&lt;P&gt;- I have many of these structures in many programs&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can I define a format to make it easier and how?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/* LAUFZEIT_CLUSTER_HJ */&lt;BR /&gt;(CASE&lt;BR /&gt;WHEN FLOOR(DATDIF(t1.VERTRBGN, t1.DTENDFLG, '30/360')/30) &amp;lt;= 6&lt;BR /&gt;THEN 6&lt;BR /&gt;WHEN FLOOR(DATDIF(t1.VERTRBGN, t1.DTENDFLG, '30/360')/30) &amp;lt;= 12&lt;BR /&gt;THEN 12&lt;BR /&gt;WHEN FLOOR(DATDIF(t1.VERTRBGN, t1.DTENDFLG, '30/360')/30) &amp;lt;= 18&lt;BR /&gt;THEN 18&lt;BR /&gt;WHEN FLOOR(DATDIF(t1.VERTRBGN, t1.DTENDFLG, '30/360')/30) &amp;lt;= 24&lt;BR /&gt;THEN 24&lt;BR /&gt;WHEN FLOOR(DATDIF(t1.VERTRBGN, t1.DTENDFLG, '30/360')/30) &amp;lt;= 30&lt;BR /&gt;THEN 30&lt;BR /&gt;WHEN FLOOR(DATDIF(t1.VERTRBGN, t1.DTENDFLG, '30/360')/30) &amp;lt;= 36&lt;BR /&gt;THEN 36&lt;BR /&gt;WHEN FLOOR(DATDIF(t1.VERTRBGN, t1.DTENDFLG, '30/360')/30) &amp;lt;= 42&lt;BR /&gt;THEN 42&lt;BR /&gt;WHEN FLOOR(DATDIF(t1.VERTRBGN, t1.DTENDFLG, '30/360')/30) &amp;lt;= 48&lt;BR /&gt;THEN 48&lt;BR /&gt;WHEN FLOOR(DATDIF(t1.VERTRBGN, t1.DTENDFLG, '30/360')/30) &amp;lt;= 54&lt;BR /&gt;THEN 54&lt;BR /&gt;WHEN FLOOR(DATDIF(t1.VERTRBGN, t1.DTENDFLG, '30/360')/30) &amp;lt;= 60&lt;BR /&gt;THEN 60&lt;BR /&gt;WHEN FLOOR(DATDIF(t1.VERTRBGN, t1.DTENDFLG, '30/360')/30) &amp;lt;= 66&lt;BR /&gt;THEN 66&lt;BR /&gt;WHEN FLOOR(DATDIF(t1.VERTRBGN, t1.DTENDFLG, '30/360')/30) &amp;lt;= 72&lt;BR /&gt;THEN 72&lt;BR /&gt;WHEN FLOOR(DATDIF(t1.VERTRBGN, t1.DTENDFLG, '30/360')/30) &amp;lt;= 78&lt;BR /&gt;THEN 78&lt;BR /&gt;WHEN FLOOR(DATDIF(t1.VERTRBGN, t1.DTENDFLG, '30/360')/30) &amp;lt;= 84&lt;BR /&gt;THEN 84&lt;BR /&gt;WHEN FLOOR(DATDIF(t1.VERTRBGN, t1.DTENDFLG, '30/360')/30) &amp;lt;= 90&lt;BR /&gt;THEN 90&lt;BR /&gt;WHEN FLOOR(DATDIF(t1.VERTRBGN, t1.DTENDFLG, '30/360')/30) &amp;lt;= 96&lt;BR /&gt;THEN 96&lt;BR /&gt;WHEN FLOOR(DATDIF(t1.VERTRBGN, t1.DTENDFLG, '30/360')/30) &amp;lt;= 120&lt;BR /&gt;THEN 120&lt;BR /&gt;ELSE 10000&lt;BR /&gt;END) FORMAT=BESTX12. AS LAUFZEIT_CLUSTER_HJ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;PY&lt;/P&gt;</description>
      <pubDate>Thu, 23 Apr 2020 14:24:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/format-based-on-more-than-1-variable/m-p/642244#M21856</guid>
      <dc:creator>PierreYvesILY</dc:creator>
      <dc:date>2020-04-23T14:24:31Z</dc:date>
    </item>
    <item>
      <title>Re: format based on more than 1 variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/format-based-on-more-than-1-variable/m-p/642273#M21858</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Except for the last two categories, you should be able to collapse the logic to:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;WHEN FLOOR(DATDIF(t1.VERTRBGN, t1.DTENDFLG, '30/360')/30) &amp;lt;= 96
THEN 

&lt;FONT color="#FF0000"&gt;ceil(&lt;/FONT&gt;FLOOR(DATDIF(t1.VERTRBGN, t1.DTENDFLG, '30/360')/30) &lt;FONT color="#FF0000"&gt;/ 6) * 6&lt;/FONT&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Apr 2020 15:03:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/format-based-on-more-than-1-variable/m-p/642273#M21858</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2020-04-23T15:03:50Z</dc:date>
    </item>
    <item>
      <title>Re: format based on more than 1 variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/format-based-on-more-than-1-variable/m-p/642292#M21859</link>
      <description>&lt;P&gt;I don't understand the question.&amp;nbsp; You aren't using a format now. And the logic you are using now is NOT using more than one variable.&amp;nbsp; It is just testing the result of the FLOOR(DATADIF()) result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The problem you will have is that you want as output a NUMBER and a FORMAT always returns TEXT.&amp;nbsp; You can use an INFORMAT to convert TEXT to numbers, but your input is a number, not text.&amp;nbsp; &amp;nbsp;It might just be easier to create a FORMAT and pass the value INPUT() function to convert the text the format generates to a number.&lt;/P&gt;
&lt;P&gt;So in a data step you could run this assignment statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;LAUFZEIT_CLUSTER_HJ = input(put(FLOOR(DATDIF(....)),MYFORMAT.),32.);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Apr 2020 15:17:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/format-based-on-more-than-1-variable/m-p/642292#M21859</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-04-23T15:17:17Z</dc:date>
    </item>
    <item>
      <title>Re: format based on more than 1 variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/format-based-on-more-than-1-variable/m-p/642303#M21860</link>
      <description>&lt;P&gt;I use 2 variables:&amp;nbsp;VERTRBGN and DTENDFLG, in a function. It's using the difference between those 2 dates to build a cluster : for instance, if&amp;nbsp;DTENDFLG -&amp;nbsp;VERTRBGN &amp;lt; 12, the cluster is labelled '12'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My question is how to create the format that would give the same result as the code that I posted. My result can be in text or in character, it's not important for this step.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Apr 2020 15:37:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/format-based-on-more-than-1-variable/m-p/642303#M21860</guid>
      <dc:creator>PierreYvesILY</dc:creator>
      <dc:date>2020-04-23T15:37:01Z</dc:date>
    </item>
    <item>
      <title>Re: format based on more than 1 variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/format-based-on-more-than-1-variable/m-p/642327#M21861</link>
      <description>&lt;P&gt;Formats always apply to a single variable. If you want the calculation done then that is a function and you pass the result of the function to a format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A format, is basically a look up table that takes a single value and compares it to individual values or a range of values to return the value label indicated for the range.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Apr 2020 16:18:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/format-based-on-more-than-1-variable/m-p/642327#M21861</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-04-23T16:18:40Z</dc:date>
    </item>
    <item>
      <title>Re: format based on more than 1 variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/format-based-on-more-than-1-variable/m-p/642339#M21862</link>
      <description>&lt;P&gt;Do you want the FLOOR() or not?&amp;nbsp; The difference is which category does 6.5 get displayed as?&amp;nbsp; 6 or 12?&lt;/P&gt;
&lt;P&gt;Does the DATDIF() even return non-integer values?&lt;/P&gt;
&lt;P&gt;If you want 6.5 to display as 6 then set the upper bounds on the ranges to 7,13, etc and exclude the upper bounds.&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format ;
value myformat 
low -&amp;lt; 7 = '6'
  7 -&amp;lt; 13 = '12'
 13 -&amp;lt; 19 = '18'
 19 -&amp;lt; 25 = '24'
 25 -&amp;lt; 31 = '30'
 31 -&amp;lt; 37 = '36'
 37 -&amp;lt; 43 = '42'
 43 -&amp;lt; 49 = '48'
 49 -&amp;lt; 55 = '54'
 55 -&amp;lt; 61 = '68'
 61 -&amp;lt; 67 = '66'
 67 -&amp;lt; 73 = '72'
 73 -&amp;lt; 79 = '78'
 79 -&amp;lt; 85 = '84'
 85 -&amp;lt; 91 = '90'
 91 -&amp;lt; 97 = '96'
 97 -&amp;lt; 121= '120'
121 - high = '10000'
 other = 'Missing'
 ;
run;

data test;
 do i=6 to 18 by 6,96,120;
  put i= @ ;   
   do x=i-0.5,i,i+0.5,i+1;

     result=put(x,myformat.);
     output;
  end;
  put;
end;
run;
proc print;
  by i ;
  id i;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;  i      x      result

  6      5.5    6
         6.0    6
         6.5    6
         7.0    12


 12     11.5    12
        12.0    12
        12.5    12
        13.0    18


 18     17.5    18
        18.0    18
        18.5    18
        19.0    24


 96     95.5    96
        96.0    96
        96.5    96
        97.0    120


120    119.5    120
       120.0    120
       120.5    120
       121.0    10000&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Apr 2020 16:54:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/format-based-on-more-than-1-variable/m-p/642339#M21862</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-04-23T16:54:30Z</dc:date>
    </item>
  </channel>
</rss>

