<?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 Finding a set of characters in observations in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Finding-a-set-of-characters-in-observations/m-p/766466#M242913</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I basically want to find a string of characters from an observation. For example, some of the observations in a diagnosis column are:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Z34.3, Z78.0, Z59.1, Z63.2&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Z53.3, Z54.3, Z59.2, Z87.3&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to find how many Z59 are there in this column. How do I write the code in SAS so that I get the frequency of Z59 irrespective of what's there after the point?&lt;/P&gt;</description>
    <pubDate>Tue, 07 Sep 2021 19:18:36 GMT</pubDate>
    <dc:creator>Gayatrikunchay</dc:creator>
    <dc:date>2021-09-07T19:18:36Z</dc:date>
    <item>
      <title>Finding a set of characters in observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-a-set-of-characters-in-observations/m-p/766466#M242913</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I basically want to find a string of characters from an observation. For example, some of the observations in a diagnosis column are:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Z34.3, Z78.0, Z59.1, Z63.2&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Z53.3, Z54.3, Z59.2, Z87.3&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to find how many Z59 are there in this column. How do I write the code in SAS so that I get the frequency of Z59 irrespective of what's there after the point?&lt;/P&gt;</description>
      <pubDate>Tue, 07 Sep 2021 19:18:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-a-set-of-characters-in-observations/m-p/766466#M242913</guid>
      <dc:creator>Gayatrikunchay</dc:creator>
      <dc:date>2021-09-07T19:18:36Z</dc:date>
    </item>
    <item>
      <title>Re: Finding a set of characters in observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-a-set-of-characters-in-observations/m-p/766469#M242916</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
&amp;nbsp; &amp;nbsp; set have;
&amp;nbsp; &amp;nbsp; count=0;
&amp;nbsp; &amp;nbsp; do i=1 to countw(diagnosis,',');
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if scan(diagnosis,i,',')=:'Z59' then count=count+1;
&amp;nbsp; &amp;nbsp; end;
    drop i;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Sep 2021 19:37:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-a-set-of-characters-in-observations/m-p/766469#M242916</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-09-07T19:37:41Z</dc:date>
    </item>
    <item>
      <title>Re: Finding a set of characters in observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-a-set-of-characters-in-observations/m-p/766470#M242917</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is this what you are after?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
 infile cards delimiter=','; 
 input zvar $ @@;
 z2=scan(zvar,1,'.');
cards;
Z34.3, Z78.0, Z59.1, Z63.2
Z53.3, Z54.3, Z59.2, Z87.3
;
run;

PROC FREQ data=have;
 tables z2 / out=want;
run;

proc print data=want;
run;
/* end of program */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Tue, 07 Sep 2021 19:40:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-a-set-of-characters-in-observations/m-p/766470#M242917</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2021-09-07T19:40:42Z</dc:date>
    </item>
    <item>
      <title>Re: Finding a set of characters in observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-a-set-of-characters-in-observations/m-p/766471#M242918</link>
      <description>&lt;P&gt;Hey,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your reply. No, I actually only want to know how many Z59's are there in the column. So in this example, there are 2 but I have 800 observations. Is there another way to do it? Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 07 Sep 2021 19:50:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-a-set-of-characters-in-observations/m-p/766471#M242918</guid>
      <dc:creator>Gayatrikunchay</dc:creator>
      <dc:date>2021-09-07T19:50:16Z</dc:date>
    </item>
    <item>
      <title>Re: Finding a set of characters in observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-a-set-of-characters-in-observations/m-p/766476#M242920</link>
      <description>&lt;P&gt;Something like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
 input diagnosis $ 1-30;
cards;
Z34.3, Z78.0, Z59.1, Z63.2
Z53.3, Z54.3, Z59.2, Z87.3
;
run;

data want;
    set have;
    countZ59=0;
    do i=1 to countc(diagnosis,',');
     if scan(diagnosis,i,',')=:' Z59' 
      then countZ59=countZ59+1;
    end;
    drop i;
run;

proc means data=want SUM nway;
 var countZ59;
run;
/* end of program */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Tue, 07 Sep 2021 20:19:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-a-set-of-characters-in-observations/m-p/766476#M242920</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2021-09-07T20:19:35Z</dc:date>
    </item>
    <item>
      <title>Re: Finding a set of characters in observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-a-set-of-characters-in-observations/m-p/766495#M242927</link>
      <description>&lt;P&gt;Like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
   select scan(ZVAR,1) as Z2, count(*) as COUNT from HAVE group by 1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Sep 2021 23:00:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-a-set-of-characters-in-observations/m-p/766495#M242927</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-09-07T23:00:27Z</dc:date>
    </item>
    <item>
      <title>Re: Finding a set of characters in observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-a-set-of-characters-in-observations/m-p/766560#M242949</link>
      <description>&lt;PRE&gt;data have;
input x $80.;
cards;
Z34.3, Z78.0, Z59.1, Z63.2
Z53.3, Z54.3, Z59.2, Z87.3
Z59.2, Z87.3, Z59.2, Z87.3
;
run;

proc sql;
select sum(count(x,'Z59')) as n from have;
quit;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Sep 2021 12:40:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-a-set-of-characters-in-observations/m-p/766560#M242949</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-09-08T12:40:03Z</dc:date>
    </item>
    <item>
      <title>Re: Finding a set of characters in observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-a-set-of-characters-in-observations/m-p/766598#M242970</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/342436"&gt;@Gayatrikunchay&lt;/a&gt;&amp;nbsp;: a wealth of solutions to choose from, I would say.&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Wed, 08 Sep 2021 14:54:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-a-set-of-characters-in-observations/m-p/766598#M242970</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2021-09-08T14:54:27Z</dc:date>
    </item>
    <item>
      <title>Re: Finding a set of characters in observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-a-set-of-characters-in-observations/m-p/851140#M336377</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have just noticed my solution does not work with 'Z59' in the very first 3 positions.&lt;/P&gt;
&lt;P&gt;Because my search is for ' Z59' (remark the leading space).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Mon, 26 Dec 2022 15:12:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-a-set-of-characters-in-observations/m-p/851140#M336377</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2022-12-26T15:12:15Z</dc:date>
    </item>
  </channel>
</rss>

