<?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 number of instances in character variables and then filter? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-Count-number-of-instances-in-character-variables-and-then/m-p/579708#M164590</link>
    <description>&lt;P&gt;Change your data structure to long (patient_ID visit_ID proc_ID) and everything will get simpler to do in SAS.&lt;/P&gt;</description>
    <pubDate>Wed, 07 Aug 2019 18:02:34 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2019-08-07T18:02:34Z</dc:date>
    <item>
      <title>How to Count number of instances in character variables and then filter?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Count-number-of-instances-in-character-variables-and-then/m-p/579689#M164577</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am looking to create a new variable that will count the occurrence of a set of columns if they have characters inside of them. The dataset I am working with contains ER visits within a year of people who eventually died from X. So there are roughly 3 thousand visits and they are already sorted by a variable that ensures each patient has all there er visits in sequence. So for example if patient A went to the ER 5 times in the past year, there are 5 rows with different information but all the same patient id. I want to form a new variable that counts the number of procedures per patient. Each visit has a procedure1-procedure20 with some missing and a lot of blank. Is there any way to form a count array or something that can count each procedure and then filter it by patient, then to add up the total?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Aug 2019 16:14:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Count-number-of-instances-in-character-variables-and-then/m-p/579689#M164577</guid>
      <dc:creator>dellerrrr</dc:creator>
      <dc:date>2019-08-07T16:14:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to Count number of instances in character variables and then filter?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Count-number-of-instances-in-character-variables-and-then/m-p/579691#M164579</link>
      <description>&lt;P&gt;please provide sample data for better response.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Aug 2019 16:23:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Count-number-of-instances-in-character-variables-and-then/m-p/579691#M164579</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2019-08-07T16:23:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to Count number of instances in character variables and then filter?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Count-number-of-instances-in-character-variables-and-then/m-p/579692#M164580</link>
      <description>&lt;P&gt;I.E. the data is something like this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Paitent ID&amp;nbsp; &amp;nbsp;Proc1&amp;nbsp; &amp;nbsp;Proc2&amp;nbsp; &amp;nbsp;Proc3&amp;nbsp; &amp;nbsp;Proc4&amp;nbsp; &amp;nbsp;Proc5...&amp;nbsp; &amp;nbsp;Proc20&lt;/P&gt;&lt;P&gt;12&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2344&amp;nbsp; &amp;nbsp; 1233&amp;nbsp; &amp;nbsp; &amp;nbsp; 894&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;12&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1902&lt;/P&gt;&lt;P&gt;12&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;111&amp;nbsp; &amp;nbsp; &amp;nbsp; 2344&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;9001&amp;nbsp; &amp;nbsp; 2020&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;12&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;234&lt;/P&gt;&lt;P&gt;13&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;232&amp;nbsp; &amp;nbsp; &amp;nbsp; 3934&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3434&lt;/P&gt;&lt;P&gt;13&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1444&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A patient can appear from anywhere from 1 time to up to 150 times in a row&lt;/P&gt;</description>
      <pubDate>Wed, 07 Aug 2019 16:28:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Count-number-of-instances-in-character-variables-and-then/m-p/579692#M164580</guid>
      <dc:creator>dellerrrr</dc:creator>
      <dc:date>2019-08-07T16:28:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to Count number of instances in character variables and then filter?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Count-number-of-instances-in-character-variables-and-then/m-p/579698#M164585</link>
      <description>&lt;P&gt;please try the below code, please replace the number of variables , at the moment since in the sample data we have 3 variables i mentioned 3, but depending on the number of variables you can replace this 3 in array as well as cnt variable derivation. The CNT2 variable will have the actual count you are expecting. Hope this helps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Paitent_ID:   Proc1:   Proc2:   Proc3:   ;
cards;
12 2344 1233 894   
12 1902 . .
12 111 2344 9001    
12 234 . .
13 232 3934 3434
13 1444 . .
;

data want;
set have;
by Paitent_ID;
array vars(3) proc1-proc3;
cnt=3-nmiss(of proc1-proc3);
retain cnt2;
if first.Paitent_ID then cnt2=cnt;
else cnt2+cnt;
if last.Paitent_ID;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Aug 2019 17:06:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Count-number-of-instances-in-character-variables-and-then/m-p/579698#M164585</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2019-08-07T17:06:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to Count number of instances in character variables and then filter?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Count-number-of-instances-in-character-variables-and-then/m-p/579708#M164590</link>
      <description>&lt;P&gt;Change your data structure to long (patient_ID visit_ID proc_ID) and everything will get simpler to do in SAS.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Aug 2019 18:02:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Count-number-of-instances-in-character-variables-and-then/m-p/579708#M164590</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-08-07T18:02:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to Count number of instances in character variables and then filter?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Count-number-of-instances-in-character-variables-and-then/m-p/579712#M164594</link>
      <description>&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Aug 2019 18:05:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Count-number-of-instances-in-character-variables-and-then/m-p/579712#M164594</guid>
      <dc:creator>dellerrrr</dc:creator>
      <dc:date>2019-08-07T18:05:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to Count number of instances in character variables and then filter?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Count-number-of-instances-in-character-variables-and-then/m-p/579715#M164596</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Paitent_ID:   Proc1:   Proc2:   Proc3:   ;
cards;
12 2344 1233 894   
12 1902 . .
12 111 2344 9001    
12 234 . .
13 232 3934 3434
13 1444 . .
;

data want;
do until(last.Paitent_ID);
set have;
by  Paitent_ID;;
count=sum(count,n(of pro:));
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Aug 2019 18:14:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Count-number-of-instances-in-character-variables-and-then/m-p/579715#M164596</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-08-07T18:14:18Z</dc:date>
    </item>
  </channel>
</rss>

