<?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 count the number of observations that meet certain conditions using proc tabulate in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/how-to-count-the-number-of-observations-that-meet-certain/m-p/426551#M22408</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/172752"&gt;@UshaLatha&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need the counts to calculate the % of data with default_flag=1.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So sub-setting of data would not help.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sum of Default_flag will give count of values =1 if default_flag is only coded 1/0.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want (count of default_flag = 1 for intersection of formatted LFV and FICO / total number of&amp;nbsp;records in data set) as a percentage&amp;nbsp;you will need that to be calculated outside of proc tabulate.&lt;/P&gt;
&lt;P&gt;If you want (count of default_flag = 1 for intersection of formatted LFV and FICO / total number of default_flag = 1 in data set)&amp;nbsp; as a percentage then you would want to make default flag a class variable with pctn but that would be also likely violate some version OR SUBSET the data to default_flag=1 with a where statement and N and PCTN for the other class variables on the table statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might have to more completely describe you numerator and denominators for the percentage if it is something else you want for a percentage.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or provide a small data set and show us what the result for that data set should be.&lt;/P&gt;</description>
    <pubDate>Wed, 10 Jan 2018 17:19:36 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2018-01-10T17:19:36Z</dc:date>
    <item>
      <title>how to count the number of observations that meet certain conditions using proc tabulate</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/how-to-count-the-number-of-observations-that-meet-certain/m-p/426330#M22399</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need some help in analysis of residential mortgage data.&lt;/P&gt;&lt;P&gt;I have some fields like FICO score , LTV , Default flag in the data.&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;FICO&lt;/TD&gt;&lt;TD&gt;LTV&lt;/TD&gt;&lt;TD&gt;DEFAULT_FLAG&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;551&lt;/TD&gt;&lt;TD&gt;50&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;752&lt;/TD&gt;&lt;TD&gt;75&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;713&lt;/TD&gt;&lt;TD&gt;83&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;400&lt;/TD&gt;&lt;TD&gt;90&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need a matrix which can give the joint distribution of FICO and LTV for the default rate. For eg, I have 1000 loans, of which 239 have defaulted (i.e default_flag=1) , which have LTV&amp;lt;70 and FICO&amp;lt;710, so the default rate should be 239/1000=0.239.. Similarly distribution for all the bucket ranges of LTV and FICO score is needed.&lt;/P&gt;&lt;P&gt;My desired distribution table should be like this:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;LTV&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Low&amp;nbsp; (&amp;lt;70)&lt;/TD&gt;&lt;TD&gt;Medium (70,80)&lt;/TD&gt;&lt;TD&gt;High(80,85)&lt;/TD&gt;&lt;TD&gt;Very high(&amp;gt;85)&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;FICO&lt;/TD&gt;&lt;TD&gt;Low (&amp;lt;710)&lt;/TD&gt;&lt;TD&gt;0.239&lt;/TD&gt;&lt;TD&gt;4.95&lt;/TD&gt;&lt;TD&gt;5.53&lt;/TD&gt;&lt;TD&gt;9.97&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Medium(710,750)&lt;/TD&gt;&lt;TD&gt;1.5&lt;/TD&gt;&lt;TD&gt;3.42&lt;/TD&gt;&lt;TD&gt;4.2&lt;/TD&gt;&lt;TD&gt;5.2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;High(750,755)&lt;/TD&gt;&lt;TD&gt;0.23&lt;/TD&gt;&lt;TD&gt;3.21&lt;/TD&gt;&lt;TD&gt;2.31&lt;/TD&gt;&lt;TD&gt;3.2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Very high &amp;gt;755&lt;/TD&gt;&lt;TD&gt;0.34&lt;/TD&gt;&lt;TD&gt;0.26&lt;/TD&gt;&lt;TD&gt;0.78&lt;/TD&gt;&lt;TD&gt;1.34&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code I have used is as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc tabulate data=test;
format LTV ltv_fmt. FICO fico_fmt. ;
class FICO LTV;
var DEFAULT_FLAG;
table FICO, LTV*DEFAULT_FLAG=" "*(N="count" PCTN="%");
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This code is giving the count of rows (irrespective of value of default_flag value) which fall into that particular ranges of LTV and FICO. But I need count of rows where DEFAULT_FLAG=1.&lt;/P&gt;&lt;P&gt;Please help me with this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2018 13:47:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/how-to-count-the-number-of-observations-that-meet-certain/m-p/426330#M22399</guid>
      <dc:creator>UshaLatha</dc:creator>
      <dc:date>2018-01-10T13:47:55Z</dc:date>
    </item>
    <item>
      <title>Re: how to count the number of observations that meet certain conditions using proc tabulate</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/how-to-count-the-number-of-observations-that-meet-certain/m-p/426456#M22404</link>
      <description>&lt;P&gt;Can you subset the data before the Proc Tabulate?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
	set have;
	if default_flag = 1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;proc&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;tabulate&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;want&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2018 14:25:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/how-to-count-the-number-of-observations-that-meet-certain/m-p/426456#M22404</guid>
      <dc:creator>HB</dc:creator>
      <dc:date>2018-01-10T14:25:26Z</dc:date>
    </item>
    <item>
      <title>Re: how to count the number of observations that meet certain conditions using proc tabulate</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/how-to-count-the-number-of-observations-that-meet-certain/m-p/426462#M22405</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need the counts to calculate the % of data with default_flag=1.&amp;nbsp;&lt;/P&gt;&lt;P&gt;So sub-setting of data would not help.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2018 14:34:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/how-to-count-the-number-of-observations-that-meet-certain/m-p/426462#M22405</guid>
      <dc:creator>UshaLatha</dc:creator>
      <dc:date>2018-01-10T14:34:42Z</dc:date>
    </item>
    <item>
      <title>Re: how to count the number of observations that meet certain conditions using proc tabulate</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/how-to-count-the-number-of-observations-that-meet-certain/m-p/426520#M22407</link>
      <description>&lt;P&gt;Assuming your formats work as intended and you want a table only related to the default_flag=1 then I would start with:&lt;/P&gt;
&lt;PRE&gt;proc tabulate data=test;
   where default_flag=1;
   format LTV ltv_fmt. FICO fico_fmt. ;
   class FICO LTV;

   table FICO ,
         LTV*(N="count" PCTN="%");
run;&lt;/PRE&gt;
&lt;P&gt;or possibly to get one table for each level of default_flag&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc tabulate data=test;
   class  default_flag;
   format LTV ltv_fmt. FICO fico_fmt. ;
   class FICO LTV;

   table default_flag,
         FICO ,
         LTV*(N="count" PCTN="%");
run;&lt;/PRE&gt;
&lt;P&gt;BTW formats that you cannot tell what the actual end points are such as&lt;/P&gt;
&lt;P&gt;'Medium(710,750)' and 'High(750,755)' are very problematic. Which category does a score of exactly 750 fit into? Not obvious from the displayed text.&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2018 16:12:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/how-to-count-the-number-of-observations-that-meet-certain/m-p/426520#M22407</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-01-10T16:12:40Z</dc:date>
    </item>
    <item>
      <title>Re: how to count the number of observations that meet certain conditions using proc tabulate</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/how-to-count-the-number-of-observations-that-meet-certain/m-p/426551#M22408</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/172752"&gt;@UshaLatha&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need the counts to calculate the % of data with default_flag=1.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So sub-setting of data would not help.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sum of Default_flag will give count of values =1 if default_flag is only coded 1/0.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want (count of default_flag = 1 for intersection of formatted LFV and FICO / total number of&amp;nbsp;records in data set) as a percentage&amp;nbsp;you will need that to be calculated outside of proc tabulate.&lt;/P&gt;
&lt;P&gt;If you want (count of default_flag = 1 for intersection of formatted LFV and FICO / total number of default_flag = 1 in data set)&amp;nbsp; as a percentage then you would want to make default flag a class variable with pctn but that would be also likely violate some version OR SUBSET the data to default_flag=1 with a where statement and N and PCTN for the other class variables on the table statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might have to more completely describe you numerator and denominators for the percentage if it is something else you want for a percentage.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or provide a small data set and show us what the result for that data set should be.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2018 17:19:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/how-to-count-the-number-of-observations-that-meet-certain/m-p/426551#M22408</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-01-10T17:19:36Z</dc:date>
    </item>
  </channel>
</rss>

