<?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: Help - count horizontally with a numeric condition in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Help-count-horizontally-with-a-numeric-condition/m-p/862907#M38122</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/440358"&gt;@kritiment&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;P class=""&gt;I have a dataset with 1 million records and 24 variables (with the same prefix for example month_1, month_2, month_3 up to month_24), plus ID.&lt;/P&gt;&lt;P class=""&gt;For each record i want to count the number of month_: where month_x is greater than 0.&lt;/P&gt;&lt;P class=""&gt;How do I achieve this?&lt;/P&gt;&lt;P class=""&gt;Any suggestion would be really appreciated.&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P class=""&gt;I got this,..&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 08 Mar 2023 11:35:02 GMT</pubDate>
    <dc:creator>kritiment</dc:creator>
    <dc:date>2023-03-08T11:35:02Z</dc:date>
    <item>
      <title>Help - count horizontally with a numeric condition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Help-count-horizontally-with-a-numeric-condition/m-p/862264#M38089</link>
      <description>&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;P class=""&gt;I have a dataset with 1 million records and 24 variables (with the same prefix for example month_1, month_2, month_3 up to month_24), plus ID.&lt;/P&gt;&lt;P class=""&gt;For each record i want to count the number of month_: where month_x is greater than 0.&lt;/P&gt;&lt;P class=""&gt;How do I achieve this?&lt;/P&gt;&lt;P class=""&gt;Any suggestion would be really appreciated.&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Sat, 04 Mar 2023 07:51:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Help-count-horizontally-with-a-numeric-condition/m-p/862264#M38089</guid>
      <dc:creator>kritiment</dc:creator>
      <dc:date>2023-03-04T07:51:59Z</dc:date>
    </item>
    <item>
      <title>Re: Help - count horizontally with a numeric condition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Help-count-horizontally-with-a-numeric-condition/m-p/862266#M38090</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=have out=long;
by id;
var month_:;
run;

proc sql;
create table want as
  select
    id,
    sum(col1 &amp;gt; 0) as count
  from long
  group by id
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Maxim 19: Long Beats Wide.&lt;/P&gt;</description>
      <pubDate>Sat, 04 Mar 2023 08:20:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Help-count-horizontally-with-a-numeric-condition/m-p/862266#M38090</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-03-04T08:20:32Z</dc:date>
    </item>
    <item>
      <title>Re: Help - count horizontally with a numeric condition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Help-count-horizontally-with-a-numeric-condition/m-p/862290#M38094</link>
      <description>&lt;P&gt;Do you actually have values of 0 or are they missing? Different beasts in SAS.&lt;/P&gt;
&lt;P&gt;If the variables have missing instead of 0 or negative values in a data step;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;countmonth = n(of month_: );&lt;/P&gt;</description>
      <pubDate>Sat, 04 Mar 2023 14:37:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Help-count-horizontally-with-a-numeric-condition/m-p/862290#M38094</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-03-04T14:37:30Z</dc:date>
    </item>
    <item>
      <title>Re: Help - count horizontally with a numeric condition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Help-count-horizontally-with-a-numeric-condition/m-p/862322#M38095</link>
      <description>&lt;P&gt;Long beats wide certainly applies.&lt;/P&gt;
&lt;P&gt;Below how you can dynamically build an expression where zero or missing becomes 0 and any other value 1 so that you just can sum the elements to get your count.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  array month_ {24} 8;
  month_7=10;
  month_9=5;
  month_24=-10;
  month_2=0;
run;

%let expr_list=;
proc sql;
  select catx(' ',name,'not in (0,.)') into :expr_list separated by ','
  from dictionary.columns
  where libname='WORK' and memname='HAVE' and upcase(name) like 'MONTH^_%' escape '^'
  ;
quit;
%put %nrbquote(&amp;amp;expr_list);

data want;
  length cnt_not0orMiss 8;
  set have;
  cnt_not0orMiss=sum(&amp;amp;expr_list);
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 04 Mar 2023 23:27:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Help-count-horizontally-with-a-numeric-condition/m-p/862322#M38095</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-03-04T23:27:25Z</dc:date>
    </item>
    <item>
      <title>Re: Help - count horizontally with a numeric condition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Help-count-horizontally-with-a-numeric-condition/m-p/862907#M38122</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/440358"&gt;@kritiment&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;P class=""&gt;I have a dataset with 1 million records and 24 variables (with the same prefix for example month_1, month_2, month_3 up to month_24), plus ID.&lt;/P&gt;&lt;P class=""&gt;For each record i want to count the number of month_: where month_x is greater than 0.&lt;/P&gt;&lt;P class=""&gt;How do I achieve this?&lt;/P&gt;&lt;P class=""&gt;Any suggestion would be really appreciated.&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P class=""&gt;I got this,..&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2023 11:35:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Help-count-horizontally-with-a-numeric-condition/m-p/862907#M38122</guid>
      <dc:creator>kritiment</dc:creator>
      <dc:date>2023-03-08T11:35:02Z</dc:date>
    </item>
  </channel>
</rss>

