<?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: Create a count using conditional statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-a-count-using-conditional-statement/m-p/926665#M364675</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp; Thank you. This is great.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I notice a slight issue. Let say i have the same individual with a record like this. for example row 219 and 220 is the same person.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="CathyVI_0-1714586107942.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/96102iB047536B9524CD3C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="CathyVI_0-1714586107942.png" alt="CathyVI_0-1714586107942.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I make this individual to be counted as&amp;nbsp; multiple instead of counting them in each Event46 B only and Event46 C only group. I noticed it is only one person with one date form (event46). That is, they filled the form one single day that is why event46 is both 1 for them. If i am counting them separate, that means I am double counting them because of their event type. However, It is one record actually assuming I transpose the records, they will be counted as multiple because they have 1-1.&amp;nbsp;&amp;nbsp;I want this to only apply to the Event46&amp;nbsp; because it has grp A,B,C and this grp is making us count someone with the same record twice.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp; if you can add an ID variable to the data and some will have 2 records, this will be nice. Row 219 &amp;amp; 220 will be a good example.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 01 May 2024 18:14:15 GMT</pubDate>
    <dc:creator>CathyVI</dc:creator>
    <dc:date>2024-05-01T18:14:15Z</dc:date>
    <item>
      <title>Create a count using conditional statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-count-using-conditional-statement/m-p/925761#M364281</link>
      <description>&lt;P&gt;Hello Everyone,&lt;/P&gt;&lt;P&gt;I need help trying to find the count for the multi_event column. Here is a sample code and my output. I was able to get the count for event 1-4 only. I also want to count when event is in more than 1 column.&lt;/P&gt;&lt;PRE&gt;data have;&lt;BR /&gt;input event1 event2 event3 event4;&lt;BR /&gt;datalines;&lt;BR /&gt;. 1 . .&lt;BR /&gt;1 1 . .&lt;BR /&gt;. . 1 .&lt;BR /&gt;1 . . 1&lt;BR /&gt;1 . . .&lt;BR /&gt;. 1 . .&lt;BR /&gt;. . 1 .&lt;BR /&gt;. 1 1 1&lt;BR /&gt;. . . 1&lt;BR /&gt;1 . . .&lt;BR /&gt;. . 1 1&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/PRE&gt;&lt;P&gt;SAS output&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="CathyVI_1-1714052664656.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/95858i6E7EEA932FCBA6ED/image-size/medium?v=v2&amp;amp;px=400" role="button" title="CathyVI_1-1714052664656.png" alt="CathyVI_1-1714052664656.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Row 2 and 4 met my criteria for multi_event so they were output in multi_event.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Row 8&amp;nbsp; and 11 met the criteria but did not output. I want row 8, 11 or any other row with multiple count to be in the multi_event column.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my attempted code (My coding is not classic I will appreciate learning a better way to code it)&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data want;
set have;
if event1 ne . and event2=. and event3=. and event4=. then event1only=1;
if event2 ne . and event1=. and event3=. and event4=. then event2only=1;
if event3 ne . and event1=. and event2=. and event4=. then event3only=1;
if event4 ne . and event1=. and event2=. and event3=. then event4only=1;
if event1 ne . and (event2 ne . or  event3 ne . or event4 ne . ) then multi_event=1;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This is my final desired output is to be able to count each column like this with proc tabulate or report.&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;Event1only&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Event2Only&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Event3Only&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Event4Only&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Multi_event&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;2&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;2&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;2&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;3&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 25 Apr 2024 13:55:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-count-using-conditional-statement/m-p/925761#M364281</guid>
      <dc:creator>CathyVI</dc:creator>
      <dc:date>2024-04-25T13:55:40Z</dc:date>
    </item>
    <item>
      <title>Re: Create a count using conditional statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-count-using-conditional-statement/m-p/925774#M364283</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/253321"&gt;@CathyVI&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the values of &lt;FONT face="courier new,courier"&gt;event1&lt;/FONT&gt;, &lt;FONT face="courier new,courier"&gt;event2&lt;/FONT&gt;, etc.&amp;nbsp; are either 1 or missing, you can count the non-missing values with the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/n0h1d8gxwr1ml7n1qdt35v3i6u7r.htm" target="_blank" rel="noopener"&gt;N function&lt;/A&gt;&amp;nbsp;and then use the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p0zs0pv38mel2jn1in4lte2akx4d.htm" target="_blank" rel="noopener"&gt;WHICHN function&lt;/A&gt; to populate the "&lt;FONT face="courier new,courier"&gt;only&lt;/FONT&gt;..." variables. The report is easy with PROC REPORT.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want(drop=_c);
set have;
array only[4];
_c=n(of event:);
if _c&amp;gt;1 then multi=1;
else if _c=1 then only[whichn(1,of event:)]=1;
run;

proc report data=want;
column only: multi;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that variable names &lt;FONT face="courier new,courier"&gt;only1&lt;/FONT&gt;, &lt;FONT face="courier new,courier"&gt;only2&lt;/FONT&gt;, etc. with a numeric &lt;EM&gt;suffix&lt;/EM&gt; are more convenient to work with than &lt;FONT face="courier new,courier"&gt;event1only&lt;/FONT&gt;, etc.: see the array definition and the variable list in the COLUMN statement.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Apr 2024 14:43:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-count-using-conditional-statement/m-p/925774#M364283</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2024-04-25T14:43:06Z</dc:date>
    </item>
    <item>
      <title>Re: Create a count using conditional statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-count-using-conditional-statement/m-p/925777#M364285</link>
      <description>&lt;P&gt;Can you describe the rule(s) involved? Code that doesn't do what you want without explanation of what is needed makes it hard to suggest changes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have to say that without a very clear understanding of what is done in the later analysis that creating a bunch of variables like event1only, event2only, etc. makes me cringe to some extent.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the only purpose is that "count" (sum might be a better approach)&lt;/P&gt;
&lt;PRE&gt;data example;
   set have;
   array e (*) event1-event4;
   array o (*) eventOnly1 -EventOnly4;
   if sum(of e(*))=1 then  o [ whichn(1,of e(*))] =1;
   else if sum(of e(*))&amp;gt;1 then multi_event=1;
run;

Proc tabulate data=example ;
  var EventOnly: multi_event;
  table  EventOnly: multi_event,
         sum
  ;

run;&lt;/PRE&gt;
&lt;P&gt;Arrays are a one way to group variables for shorthand code. In this case using Sum of the array to tell if only one of the variables has a value of 1, or more, or all missing.&lt;/P&gt;
&lt;P&gt;Note the different naming of variables in the Array o definition. If you place a number at the end you can use a list to generate sequentially named variables. Placing a suffix like "only" after that means you have to type them all the time.&lt;/P&gt;
&lt;P&gt;The fun bit in the code is the function WHICHN which looks for the first value in a list of others. In this case it looks for a value of 1 in the 4 variables of the array E. The return is the position in the list of that variable. Since we have restricted the use to where only one variable in the list is defined that number can be used as the INDEX for the array o, which is why the whole function call is inside the [&amp;nbsp; ] brackets. Array can use either () or [] to enclose the index value of the array. I prefer the [ ] as it is easier to see which is the function index boundary when functions are involved.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I used Sum in the tabulate, N would work as well but would require VAR variables not Class because of all the missing values.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Apr 2024 14:50:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-count-using-conditional-statement/m-p/925777#M364285</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-04-25T14:50:01Z</dc:date>
    </item>
    <item>
      <title>Re: Create a count using conditional statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-count-using-conditional-statement/m-p/925823#M364299</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp; Thank you for explain this. Both codes worked but i have to read carefully to understand your coding.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;how can I add "Total" to the output table you created.&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;Only1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Only2&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Only3&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Only4&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Multi&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Total&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;2&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;2&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;2&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;4&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;11&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Thu, 25 Apr 2024 16:59:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-count-using-conditional-statement/m-p/925823#M364299</guid>
      <dc:creator>CathyVI</dc:creator>
      <dc:date>2024-04-25T16:59:21Z</dc:date>
    </item>
    <item>
      <title>Re: Create a count using conditional statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-count-using-conditional-statement/m-p/925826#M364300</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/253321"&gt;@CathyVI&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;how can I add "Total" to the output table you created.&amp;nbsp;&lt;/P&gt;
&lt;TABLE&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;Only1&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;Only2&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;Only3&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;Only4&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;Multi&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;Total&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;2&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;2&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&amp;nbsp;2&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;1&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;4&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;11&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I would compute the total in the DATA step and then add the computed variable to the COLUMN statement of the PROC REPORT step:&lt;/P&gt;
&lt;PRE&gt;&lt;FONT color="#999999"&gt;data want(drop=_c);
set have;
array only[4];
_c=n(of event:);
if _c&amp;gt;1 then multi=1;
else if _c=1 then only[whichn(1,of event:)]=1;
&lt;FONT color="#000000"&gt;&lt;STRONG&gt;total=sum(of only[*], multi, 0);&lt;/STRONG&gt;&lt;/FONT&gt;
run;

proc report data=want;
column only: multi &lt;FONT color="#000000"&gt;&lt;STRONG&gt;total&lt;/STRONG&gt;&lt;/FONT&gt;;
run;&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;The purpose of the zero in the third argument of the SUM function is to avoid log messages about missing values for (hypothetical) observations with missing values in all &lt;FONT face="courier new,courier"&gt;event&lt;/FONT&gt;... variables.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Apr 2024 17:19:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-count-using-conditional-statement/m-p/925826#M364300</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2024-04-25T17:19:18Z</dc:date>
    </item>
    <item>
      <title>Re: Create a count using conditional statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-count-using-conditional-statement/m-p/925881#M364337</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;&amp;nbsp;Thank you. I made a 2 silly mistake in my first question. My table is not (.) it is (0). Also, my columns have different names. When I tried to apply your code I did not get the missing value populated.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data have;
input event1 event2 case32 event46;
datalines;
0 1 0 0
1 1 0 0
0 0 1 0
1 0 0 1
1 0 0 0
0 1 0 0
0 0 1 0
0 1 1 1
0 0 0 1
1 0 0 0
0 0 1 1
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Sorry for the confusion. Please help.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Apr 2024 20:15:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-count-using-conditional-statement/m-p/925881#M364337</guid>
      <dc:creator>CathyVI</dc:creator>
      <dc:date>2024-04-25T20:15:18Z</dc:date>
    </item>
    <item>
      <title>Re: Create a count using conditional statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-count-using-conditional-statement/m-p/925883#M364338</link>
      <description>&lt;P&gt;Looks like the definition of "all missing" would become SUM(of events)=0 .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/253321"&gt;@CathyVI&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;&amp;nbsp;Thank you. I made a 2 silly mistake in my first question. My table is not (.) it is (0). Also, my columns have different names. When I tried to apply your code I did not get the missing value populated.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;data have;
input event1 event2 case32 event46;
datalines;
0 1 0 0
1 1 0 0
0 0 1 0
1 0 0 1
1 0 0 0
0 1 0 0
0 0 1 0
0 1 1 1
0 0 0 1
1 0 0 0
0 0 1 1
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Sorry for the confusion. Please help.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Apr 2024 20:22:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-count-using-conditional-statement/m-p/925883#M364338</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-04-25T20:22:58Z</dc:date>
    </item>
    <item>
      <title>Re: Create a count using conditional statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-count-using-conditional-statement/m-p/925886#M364340</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input event1 event2 case32 event46;
datalines;
0 1 0 0
1 1 0 0
0 0 1 0
1 0 0 1
1 0 0 0
0 1 0 0
0 0 1 0
0 1 1 1
0 0 0 1
1 0 0 0
0 0 1 1
;
run;

data want;
set have;
array _events(*) event: case:;

length event_type $32.;
if sum(of _events(*))&amp;gt;1 then event_type = 'Multi';
else event_type = vname(_events(whichn(1, of _events(*))));

run;

proc tabulate data=want;
class event_type;
table  (event_type all="Total")*N='';
run;

proc freq data=want noprint;
table event_type / out=summary;
run;

proc print data=summary;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Many different ways to get there. 0/1 actually simplify things IMO.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Apr 2024 20:30:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-count-using-conditional-statement/m-p/925886#M364340</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2024-04-25T20:30:30Z</dc:date>
    </item>
    <item>
      <title>Re: Create a count using conditional statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-count-using-conditional-statement/m-p/925903#M364343</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Looks like the definition of "all missing" would become SUM(of events)=0 .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/253321"&gt;@CathyVI&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;&amp;nbsp;Thank you. I made a 2 silly mistake in my first question. My table is not (.) it is (0). Also, my columns have different names. When I tried to apply your code I did not get the missing value populated.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;data have;
input event1 event2 case32 event46;
datalines;
0 1 0 0
1 1 0 0
0 0 1 0
1 0 0 1
1 0 0 0
0 1 0 0
0 0 1 0
0 1 1 1
0 0 0 1
1 0 0 0
0 0 1 1
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Sorry for the confusion. Please help.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I have to assume "missing" with the above would be all 0 values correct? None are provided to demonstrate.&lt;/P&gt;
&lt;P&gt;If that assumption is correct a minor addition to &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;'s code:&lt;/P&gt;
&lt;PRE&gt;data have;
input event1 event2 case32 event46;
datalines;
0 1 0 0
1 1 0 0
0 0 1 0
1 0 0 1
1 0 0 0
0 1 0 0
0 0 1 0
0 1 1 1
0 0 0 1
1 0 0 0
0 0 1 1
0 0 0 0
;
run;

data want;
set have;
array _events(*) event1 event2 case32 event46;
length event_type $32.;
if sum(of _events(*))&amp;gt;1 then event_type = 'Multi';
else if sum(of _events(*))=0 then event_type = 'Missing';
else event_type = vname(_events(whichn(1, of _events(*))));

run;&lt;BR /&gt;
proc tabulate data=want;
class event_type;
table  (event_type all="Total")*N='';
run;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Apr 2024 22:00:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-count-using-conditional-statement/m-p/925903#M364343</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-04-25T22:00:18Z</dc:date>
    </item>
    <item>
      <title>Re: Create a count using conditional statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-count-using-conditional-statement/m-p/925923#M364351</link>
      <description>&lt;P&gt;And just for fun here another approach to achieve the same&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
  invalue $case
    '0000' = 0
    '1000' = 1
    '0100' = 2
    '0010' = 3
    '0001' = 4
    other  = 5
    ;
run;

data want(keep= Only1 - Only4 Multi Total);
  set have end=last;

  array src_vars{*} event1 event2 case32 event46;
  array trg_vars{*} Only1 - Only4 Multi (5*0);
  retain trg_vars;

  ind=input(cats(of src_vars[*]),$case.);

  if ind ne 0 then trg_vars[ind]=sum(trg_vars[ind],1);

  if last then 
    do;
      Total=sum(of trg_vars[*]);
      output;
    end;

run;

proc print data=want;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 26 Apr 2024 02:30:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-count-using-conditional-statement/m-p/925923#M364351</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-04-26T02:30:57Z</dc:date>
    </item>
    <item>
      <title>Re: Create a count using conditional statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-count-using-conditional-statement/m-p/925954#M364358</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/253321"&gt;@CathyVI&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;My table is not (.) it is (0). Also, my columns have different names.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879" target="_blank" rel="noopener"&gt;Reeza&lt;/A&gt;'s definition of variable&amp;nbsp;&lt;FONT face="courier new,courier"&gt;event_type&lt;/FONT&gt; is a great idea for these new requirements and, of course, using the SUM function instead of the N function.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2024 06:39:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-count-using-conditional-statement/m-p/925954#M364358</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2024-04-26T06:39:01Z</dc:date>
    </item>
    <item>
      <title>Re: Create a count using conditional statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-count-using-conditional-statement/m-p/926065#M364402</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;Thank you all. I want to add a final twist to my work. I am sorry if you expected it earlier. I am a step by step learner so I don't want to get confused with too much information at a time. This is my twist.&lt;/P&gt;&lt;P&gt;I want to add "grp" variable to event46. The grp is only available if event46 is available however grp can be available when event46 is present and other event is present e.g., case32 or event2 (this is the multi ).&lt;/P&gt;&lt;P&gt;I would like my outcome to have the event46 outcomes in their respective groups.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data have;
input event1 event2 case32 event46 grp $;
datalines;
0 1 0 0 .
1 1 0 0 .
0 0 1 0 .
1 0 0 1 A
0 0 0 1 A 
1 0 0 0 .
0 0 1 1 C
0 0 0 1 C
0 1 0 0 .
0 0 1 0 .
0 1 1 1 B
0 0 0 1 A 
1 0 0 0 .
0 0 1 1 C
0 0 0 0 .
0 0 0 1 B 
0 0 0 1 B 
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Note: if case32 and event46 are both present, I still want them in the multi. I think I can do this in pro tabulate by adding grp but did not work&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc tabulate data=want;
class event_type/ order=formatted;
table grp, (event_type all="Total")*N='';
/*table grp*(event_type all="Total")*N='' */
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Again, sorry for not addition this details earlier. Thank you so much.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2024 16:10:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-count-using-conditional-statement/m-p/926065#M364402</guid>
      <dc:creator>CathyVI</dc:creator>
      <dc:date>2024-04-26T16:10:39Z</dc:date>
    </item>
    <item>
      <title>Re: Create a count using conditional statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-count-using-conditional-statement/m-p/926067#M364404</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/253321"&gt;@CathyVI&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;Thank you all. I want to add a final twist to my work. I am sorry if you expected it earlier. I am a step by step learner so I don't want to get confused with too much information at a time. This is my twist.&lt;/P&gt;
&lt;P&gt;I want to add "grp" variable to event46. The grp is only available if event46 is available however grp can be available when event46 is present and other event is present e.g., case32 or event2 (this is the multi ).&lt;/P&gt;
&lt;P&gt;I would like my outcome to have the event46 outcomes in their respective groups.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;data have;
input event1 event2 case32 event46 grp $;
datalines;
0 1 0 0 .
1 1 0 0 .
0 0 1 0 .
1 0 0 1 A
0 0 0 1 A 
1 0 0 0 .
0 0 1 1 C
0 0 0 1 C
0 1 0 0 .
0 0 1 0 .
0 1 1 1 B
0 0 0 1 A 
1 0 0 0 .
0 0 1 1 C
0 0 0 0 .
0 0 0 1 B 
0 0 0 1 B 
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note: if case32 and event46 are both present, I still want them in the multi. I think I can do this in pro tabulate by adding grp but did not work&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;proc tabulate data=want;
class event_type/ order=formatted;
table grp, (event_type all="Total")*N='';
/*table grp*(event_type all="Total")*N='' */
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Again, sorry for not addition this details earlier. Thank you so much.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I cannot detect the rule involved with why the first two times you have this the group is A but for the last two lines it is B. You need to provide rules, not examples sometimes.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;0 0 0 1 &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2024 16:23:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-count-using-conditional-statement/m-p/926067#M364404</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-04-26T16:23:35Z</dc:date>
    </item>
    <item>
      <title>Re: Create a count using conditional statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-count-using-conditional-statement/m-p/926070#M364405</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;Thank you. There is no rule involved.&amp;nbsp; The grp variable is part of the original dataset that grouped event46 into A,B,C. event46 is group in the original data, I did not group it but i want my outout into grouping so I see the count of A only, count of B only and count of C only.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2024 16:47:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-count-using-conditional-statement/m-p/926070#M364405</guid>
      <dc:creator>CathyVI</dc:creator>
      <dc:date>2024-04-26T16:47:34Z</dc:date>
    </item>
    <item>
      <title>Re: Create a count using conditional statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-count-using-conditional-statement/m-p/926071#M364406</link>
      <description>&lt;P&gt;Sounds like you want to convert EVENT46 + GRP into some unknown number of new 0/1 variables.&amp;nbsp; Then your new problem is the same as the original problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your example data does not seem to have any ID variable(s) to uniquely identify the observations.&amp;nbsp; So let's add one, let's call it ROW.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  row+1;
  input event1 event2 case32 event46 grp $;
datalines;
0 1 0 0 .
1 1 0 0 .
0 0 1 0 .
1 0 0 1 A
0 0 0 1 A 
1 0 0 0 .
0 0 1 1 C
0 0 0 1 C
0 1 0 0 .
0 0 1 0 .
0 1 1 1 B
0 0 0 1 A 
1 0 0 0 .
0 0 1 1 C
0 0 0 0 .
0 0 0 1 B 
0 0 0 1 B 
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now we can use PROC TRANSPOSE to create EVENT46_A and EVENT46_B etc.&amp;nbsp; Which you can merge back onto your existing data using the key variable(s).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc transpose data=have prefix=event46_ out=new_vars(drop=_:);
  by row;
  where event46 ;
  id grp;
  var event46;
run;

data new_have;
  merge have new_vars;
  by row;
  drop event46 grp;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;                                            event46_    event46_    event46_
OBS    row    event1    event2    case32        A           C           B

  1      1       0         1         0          .           .           .
  2      2       1         1         0          .           .           .
  3      3       0         0         1          .           .           .
  4      4       1         0         0          1           .           .
  5      5       0         0         0          1           .           .
  6      6       1         0         0          .           .           .
  7      7       0         0         1          .           1           .
  8      8       0         0         0          .           1           .
  9      9       0         1         0          .           .           .
 10     10       0         0         1          .           .           .
 11     11       0         1         1          .           .           1
 12     12       0         0         0          1           .           .
 13     13       1         0         0          .           .           .
 14     14       0         0         1          .           1           .
 15     15       0         0         0          .           .           .
 16     16       0         0         0          .           .           1
 17     17       0         0         0          .           .           1
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2024 17:01:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-count-using-conditional-statement/m-p/926071#M364406</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-04-26T17:01:20Z</dc:date>
    </item>
    <item>
      <title>Re: Create a count using conditional statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-count-using-conditional-statement/m-p/926072#M364407</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/253321"&gt;@CathyVI&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I would like my outcome to have the event46 outcomes in their respective groups.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So you want to split the count of "event46" into counts of the subgroups&amp;nbsp;"event46 A", "event46 B", etc.?&lt;/P&gt;
&lt;P&gt;A simple solution would be to modify the value of &lt;FONT face="courier new,courier"&gt;event_type&lt;/FONT&gt; in Reeza's code accordingly, e.g., insert as the last statement in the DATA step creating dataset WANT:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if event_type='event46' then event_type=catx(' ','event46',grp);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;However, this might not suffice for a fancier report with, say, headers "A", "B", "C" and a spanning header "event46".&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2024 17:03:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-count-using-conditional-statement/m-p/926072#M364407</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2024-04-26T17:03:49Z</dc:date>
    </item>
    <item>
      <title>Re: Create a count using conditional statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-count-using-conditional-statement/m-p/926082#M364410</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp; &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp; &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;&amp;nbsp;Thank you. I am afraid to tag the rest because this is not an efficient way of requesting help. I am solving this task bit by bit. Am very sorry if this is annoying.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data have;
input event1 event2 case32 event46 grp $;
datalines;
0 1 0 0 .
1 2 0 0 .
0 0 1 0 .
1 0 0 1 A
0 0 0 1 A 
1 0 0 0 .
0 0 1 1 C
0 0 0 1 C
0 1 0 0 .
0 0 1 0 .
0 0 2 0 .
0 1 1 1 B
0 0 0 2 A 
2 0 0 0 .
0 0 1 1 C
0 0 0 0 .
0 0 0 1 B 
0 0 0 1 B 

0 2 0 0 .
2 2 0 0 .
0 0 1 0 .
2 0 0 1 A
0 0 0 1 A 
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The initial data I shared has&amp;nbsp; &amp;nbsp;0=missing days, 1=any value&amp;lt;=30 days, 2=value between 31-60 days. I mistakenly again forgot the 2. I was only sharing dataset with 0,1. Am sorry.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I used&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;code, the 2 was part of the multi.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data want;&lt;BR /&gt;set have;&lt;BR /&gt;array _events(*) event1 event2 case32 event46 ;&lt;BR /&gt;length event_type $32.;&lt;BR /&gt;if sum(of _events(*))&amp;gt;1 then event_type = 'Multiple';&lt;BR /&gt;else if sum(of _events(*))=0 then event_type = 'Missing';&lt;BR /&gt;else event_type = vname(_events(whichn(1, of _events(*))));&lt;BR /&gt;if event_type='event46' then event_type=catx(' ','event46',grp);&lt;BR /&gt;run;&lt;/PRE&gt;&lt;P&gt;This is not what I want. I want 2 to follow the counting process as 1. if you have a single 2 you will be counted differently may if i can name it event1_60, event2_60 or case32_60 and if you have 2 in more than one group you will be multi_60. Again, I know this is inefficient way of requesting help. Am sorry&lt;/P&gt;&lt;P&gt;This is the overall goal am trying to get.&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Event1&lt;/P&gt;&lt;P&gt;only&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Event2 only&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Case32 only&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Event46 A&lt;/P&gt;&lt;P&gt;only&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Event46 B&lt;/P&gt;&lt;P&gt;only&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Event46 C&lt;/P&gt;&lt;P&gt;Only&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Multiple&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&lt;STRONG&gt;Total&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;30 days&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;31-60 days&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;&lt;STRONG&gt;Total&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Fri, 26 Apr 2024 18:46:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-count-using-conditional-statement/m-p/926082#M364410</guid>
      <dc:creator>CathyVI</dc:creator>
      <dc:date>2024-04-26T18:46:55Z</dc:date>
    </item>
    <item>
      <title>Re: Create a count using conditional statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-count-using-conditional-statement/m-p/926106#M364411</link>
      <description>&lt;P&gt;Suggestion: Stop with incremental data descriptions. Give us a full description of all the variables and examples of what you want counted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are things that work with missing values that do not work with values of zero.&lt;/P&gt;
&lt;P&gt;There are things that work with 1/0 coded values that do not work with 0/1/2/3/4/5 etc.&lt;/P&gt;
&lt;P&gt;Almost everything works different with character values than numeric.&lt;/P&gt;
&lt;P&gt;So some changes of your values means that logic has to change completely.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Examples: the N function counts non-missing numeric values so a mix of . and 1 means that: N=0 all values missing; N=1 exactly 1 value not missing, N&amp;gt;1 more than one non-missing. Replace the . with 0 and you get 4 (or 5 or 25 if there are 25 variables used).&lt;/P&gt;
&lt;P&gt;So another approach. Sum of 1/0 coded numeric variables is the number of 1 values.&lt;/P&gt;
&lt;P&gt;Now throw in 2. Neither of the above work. Now each value needs to be tested to "I want 2 to follow the counting process as 1." Are your going to add in 3? then code that tests for 2 won't find it and has to be rewritten again. Is this "count" going to become dependent on more variables that have not been mentioned yet?&lt;/P&gt;
&lt;P&gt;Are non-integer values going to be involved with yet another set of rules?&lt;/P&gt;
&lt;P&gt;Here's one you aren't likely to be familiar with: what about special missing values? (There are actually 27 different missing values possible in SAS. None would normally be used for summing or such but they can be counted when needed.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is one thing to ask different questions about a single description of the data or even conditions in the data. Changing the data content is a completely different story.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2024 21:37:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-count-using-conditional-statement/m-p/926106#M364411</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-04-26T21:37:33Z</dc:date>
    </item>
    <item>
      <title>Re: Create a count using conditional statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-count-using-conditional-statement/m-p/926109#M364412</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;Thanks for the clarity. As I have said this is a mistake-anxiety issue on my part. I am a step-by-step learner but i fail to include all information earlier. lesson learn.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am not addition another variable or row after this. My data is 0,1,2. Hope you or anyone can help. Thanks again.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2024 22:12:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-count-using-conditional-statement/m-p/926109#M364412</guid>
      <dc:creator>CathyVI</dc:creator>
      <dc:date>2024-04-26T22:12:28Z</dc:date>
    </item>
    <item>
      <title>Re: Create a count using conditional statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-count-using-conditional-statement/m-p/926114#M364417</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/253321"&gt;@CathyVI&lt;/a&gt;&amp;nbsp;Given that your data is "evolving" I assume you are creating this data yourself as part of some upstream logic. It could be possible that there is a more direct way to get to the report you're after but for us to know you would need to share a representative sample of your "source" data and then describe what information you would like to surface in your report.&lt;/P&gt;</description>
      <pubDate>Sat, 27 Apr 2024 00:20:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-count-using-conditional-statement/m-p/926114#M364417</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-04-27T00:20:24Z</dc:date>
    </item>
  </channel>
</rss>

