<?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: check for list of strings within a character variable and output count in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/check-for-list-of-strings-within-a-character-variable-and-output/m-p/522781#M4501</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input mr_name $19.;
cards;
cxhimgqabout
lolfvchickbznicefx
howmefvtoldbqcv
toldyounothing
;
run;


data want;
	set have;
	
	array bigram[11]  $ ('bq','bz','cf','cj','cv','cx','fq','fv','fx','fz','gq');
	counter=0;
	do i=1 to dim(bigram);
			if index(mr_name,strip(bigram[i]) ) &amp;gt; 0 then counter=counter+1;				
	end;
	drop bigram: i;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 20 Dec 2018 03:44:42 GMT</pubDate>
    <dc:creator>r_behata</dc:creator>
    <dc:date>2018-12-20T03:44:42Z</dc:date>
    <item>
      <title>check for list of strings within a character variable and output count</title>
      <link>https://communities.sas.com/t5/New-SAS-User/check-for-list-of-strings-within-a-character-variable-and-output/m-p/522774#M4499</link>
      <description>&lt;P&gt;Hi, Please help me write code to do this task.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a list of bigram's that I want to check how many time they are occurring in mr_name field and output the counter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For&amp;nbsp; example. first row in mr_name "cxhimgqabout" has "cx" and "gq" two bigrams. So, my counter variable should say 2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="380"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="88"&gt;&lt;STRONG&gt;list of bigram&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="237"&gt;&lt;STRONG&gt;mr_name&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="55"&gt;&lt;STRONG&gt;counter&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;bq&lt;/TD&gt;
&lt;TD&gt;&lt;FONT color="#ff6600"&gt;cx&lt;/FONT&gt;him&lt;FONT color="#ff6600"&gt;gq&lt;/FONT&gt;about&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;bz&lt;/TD&gt;
&lt;TD&gt;lol&lt;FONT color="#ff6600"&gt;fv&lt;/FONT&gt;chick&lt;FONT color="#ff6600"&gt;bz&lt;/FONT&gt;nice&lt;FONT color="#ff6600"&gt;fx&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;cf&lt;/TD&gt;
&lt;TD&gt;howme&lt;FONT color="#ff6600"&gt;fv&lt;/FONT&gt;told&lt;FONT color="#ff6600"&gt;bqcv&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;cj&lt;/TD&gt;
&lt;TD&gt;toldyounothing&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;cv&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;cx&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;fq&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;fv&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;fx&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;fz&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;gq&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Thu, 20 Dec 2018 02:54:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/check-for-list-of-strings-within-a-character-variable-and-output/m-p/522774#M4499</guid>
      <dc:creator>helloSAS</dc:creator>
      <dc:date>2018-12-20T02:54:56Z</dc:date>
    </item>
    <item>
      <title>Re: check for list of strings within a character variable and output count</title>
      <link>https://communities.sas.com/t5/New-SAS-User/check-for-list-of-strings-within-a-character-variable-and-output/m-p/522779#M4500</link>
      <description>&lt;P&gt;Pretty straightforward and linear--&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
infile cards truncover
input bigram $ mr_name :$20.  ;
cards;
bq	cxhimgqabout	2
bz	lolfvchickbznicefx	3
cf	howmefvtoldbqcv	3
cj	toldyounothing 0
cv	 	 
cx	 	 
fq	 	 
fv	 	 
fx	 	 
fz	 	 
gq
;

proc transpose data=have out=w;
var bigram;
run;
data want;
set have;
if _n_=1 then set w;
array t col:;
count=0;
do i=1 to dim(t);
count+count(mr_name,strip( t(i)));
end;
drop col: i;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Dec 2018 03:38:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/check-for-list-of-strings-within-a-character-variable-and-output/m-p/522779#M4500</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-12-20T03:38:48Z</dc:date>
    </item>
    <item>
      <title>Re: check for list of strings within a character variable and output count</title>
      <link>https://communities.sas.com/t5/New-SAS-User/check-for-list-of-strings-within-a-character-variable-and-output/m-p/522781#M4501</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input mr_name $19.;
cards;
cxhimgqabout
lolfvchickbznicefx
howmefvtoldbqcv
toldyounothing
;
run;


data want;
	set have;
	
	array bigram[11]  $ ('bq','bz','cf','cj','cv','cx','fq','fv','fx','fz','gq');
	counter=0;
	do i=1 to dim(bigram);
			if index(mr_name,strip(bigram[i]) ) &amp;gt; 0 then counter=counter+1;				
	end;
	drop bigram: i;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Dec 2018 03:44:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/check-for-list-of-strings-within-a-character-variable-and-output/m-p/522781#M4501</guid>
      <dc:creator>r_behata</dc:creator>
      <dc:date>2018-12-20T03:44:42Z</dc:date>
    </item>
    <item>
      <title>Re: check for list of strings within a character variable and output count</title>
      <link>https://communities.sas.com/t5/New-SAS-User/check-for-list-of-strings-within-a-character-variable-and-output/m-p/522782#M4502</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm sorry I should have mentioned that bigrams variable and mr_name variable are in 2 different datasets. Do I need to join them to do this?&lt;/P&gt;</description>
      <pubDate>Thu, 20 Dec 2018 03:46:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/check-for-list-of-strings-within-a-character-variable-and-output/m-p/522782#M4502</guid>
      <dc:creator>helloSAS</dc:creator>
      <dc:date>2018-12-20T03:46:45Z</dc:date>
    </item>
    <item>
      <title>Re: check for list of strings within a character variable and output count</title>
      <link>https://communities.sas.com/t5/New-SAS-User/check-for-list-of-strings-within-a-character-variable-and-output/m-p/522785#M4503</link>
      <description>&lt;P&gt;OK&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/21058"&gt;@helloSAS&lt;/a&gt;&amp;nbsp; No worries, Going forward please detail your question well. Just a request, coz it only helps and saves our time&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*create two datasets bigram and name*/
data bigram(keep=bigram) name(keep=Mr_name);
infile cards truncover;
input bigram $ mr_name :$20.  ;
if not missing(mr_name) then output name;
output bigram;
cards;
bq	cxhimgqabout	2
bz	lolfvchickbznicefx	3
cf	howmefvtoldbqcv	3
cj	toldyounothing 0
cv	 	 
cx	 	 
fq	 	 
fv	 	 
fx	 	 
fz	 	 
gq
;


proc transpose data=bigram out=w(drop=_name_);
var bigram;
run;
data want;
set name;
if _n_=1 then set w;
array t col:;
count=0;
do over t;
count+count(mr_name,strip( t));
end;
drop col: ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Dec 2018 03:53:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/check-for-list-of-strings-within-a-character-variable-and-output/m-p/522785#M4503</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-12-20T03:53:45Z</dc:date>
    </item>
    <item>
      <title>Re: check for list of strings within a character variable and output count</title>
      <link>https://communities.sas.com/t5/New-SAS-User/check-for-list-of-strings-within-a-character-variable-and-output/m-p/522786#M4504</link>
      <description>&lt;P&gt;updated code, based on your new requirement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input mr_name $19.;
cards;
cxhimgqabout
lolfvchickbznicefx
howmefvtoldbqcv
toldyounothing
;
run;

data bigram;
input bigram $;
cards;
bq
bz
cf
cj
cv
cx
fq
fv
fx
fz
gq
;
run;


proc transpose data =bigram out=tmp;
var bigram;
run;

data want;
if _n_ =1 then do;
	set tmp;
end;
	set have;
	
	array bigram[11]  $ col1-col11;
	counter=0;
	do i=1 to dim(bigram);
			if index(mr_name,strip(bigram[i]) ) &amp;gt; 0 then counter=counter+1;				
	end;
	drop col: i _name_;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Dec 2018 03:55:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/check-for-list-of-strings-within-a-character-variable-and-output/m-p/522786#M4504</guid>
      <dc:creator>r_behata</dc:creator>
      <dc:date>2018-12-20T03:55:22Z</dc:date>
    </item>
    <item>
      <title>Re: check for list of strings within a character variable and output count</title>
      <link>https://communities.sas.com/t5/New-SAS-User/check-for-list-of-strings-within-a-character-variable-and-output/m-p/522787#M4505</link>
      <description>&lt;P&gt;hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;, based on my recent learning, the implicit arrays are deprecated in the latest releases, currently being supported only for backward compatibility.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Dec 2018 03:59:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/check-for-list-of-strings-within-a-character-variable-and-output/m-p/522787#M4505</guid>
      <dc:creator>r_behata</dc:creator>
      <dc:date>2018-12-20T03:59:32Z</dc:date>
    </item>
    <item>
      <title>Re: check for list of strings within a character variable and output count</title>
      <link>https://communities.sas.com/t5/New-SAS-User/check-for-list-of-strings-within-a-character-variable-and-output/m-p/522788#M4506</link>
      <description>&lt;P&gt;I am a Paul Dorfman aka Hashman and Pierre Gagnon aka PGstats&amp;nbsp;&lt;STRONG&gt;wannabe&lt;/STRONG&gt;. &lt;STRONG&gt;PD&lt;/STRONG&gt; uses that till date, so will i.&amp;nbsp; &amp;nbsp;My orientation is straight, otherwise I would ask them out on a date even though they are grey haired men. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; In love with their Brilliance&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Dec 2018 04:04:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/check-for-list-of-strings-within-a-character-variable-and-output/m-p/522788#M4506</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-12-20T04:04:04Z</dc:date>
    </item>
    <item>
      <title>Re: check for list of strings within a character variable and output count</title>
      <link>https://communities.sas.com/t5/New-SAS-User/check-for-list-of-strings-within-a-character-variable-and-output/m-p/522789#M4507</link>
      <description>&lt;P&gt;Good luck.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Dec 2018 04:11:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/check-for-list-of-strings-within-a-character-variable-and-output/m-p/522789#M4507</guid>
      <dc:creator>r_behata</dc:creator>
      <dc:date>2018-12-20T04:11:25Z</dc:date>
    </item>
    <item>
      <title>Re: check for list of strings within a character variable and output count</title>
      <link>https://communities.sas.com/t5/New-SAS-User/check-for-list-of-strings-within-a-character-variable-and-output/m-p/522795#M4509</link>
      <description>&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 20 Dec 2018 04:39:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/check-for-list-of-strings-within-a-character-variable-and-output/m-p/522795#M4509</guid>
      <dc:creator>helloSAS</dc:creator>
      <dc:date>2018-12-20T04:39:09Z</dc:date>
    </item>
    <item>
      <title>Re: check for list of strings within a character variable and output count</title>
      <link>https://communities.sas.com/t5/New-SAS-User/check-for-list-of-strings-within-a-character-variable-and-output/m-p/522799#M4511</link>
      <description>&lt;P&gt;Can you post a link to the documentation stating that implicit arrays are deprecated?&lt;/P&gt;</description>
      <pubDate>Thu, 20 Dec 2018 06:00:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/check-for-list-of-strings-within-a-character-variable-and-output/m-p/522799#M4511</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2018-12-20T06:00:48Z</dc:date>
    </item>
    <item>
      <title>Re: check for list of strings within a character variable and output count</title>
      <link>https://communities.sas.com/t5/New-SAS-User/check-for-list-of-strings-within-a-character-variable-and-output/m-p/522811#M4515</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data  result;
	set name;
	count=0;
	do i=1 to n;
		set bigram nobs=n point=i;
		if index(mr_name,strip(bigram))&amp;gt;0 then count=count+1;
	end;
	keep mr_name count;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Dec 2018 08:36:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/check-for-list-of-strings-within-a-character-variable-and-output/m-p/522811#M4515</guid>
      <dc:creator>learsaas</dc:creator>
      <dc:date>2018-12-20T08:36:31Z</dc:date>
    </item>
    <item>
      <title>Re: check for list of strings within a character variable and output count</title>
      <link>https://communities.sas.com/t5/New-SAS-User/check-for-list-of-strings-within-a-character-variable-and-output/m-p/522814#M4517</link>
      <description>&lt;P&gt;The deprecation of implicit array processing is implicit (pun intended). Neither "do over" nor the _i_ referencing method are mentioned anymore in the current documentation.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Dec 2018 09:08:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/check-for-list-of-strings-within-a-character-variable-and-output/m-p/522814#M4517</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-12-20T09:08:56Z</dc:date>
    </item>
    <item>
      <title>Re: check for list of strings within a character variable and output count</title>
      <link>https://communities.sas.com/t5/New-SAS-User/check-for-list-of-strings-within-a-character-variable-and-output/m-p/522851#M4528</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input mr_name $19.;
cards;
cxhimgqabout
lolfvchickbznicefx
howmefvtoldbqcv
toldyounothing
;
run;

data bigram;
input bigram $;
cards;
bq
bz
cf
cj
cv
cx
fq
fv
fx
fz
gq
;
run;
proc sql;
create table want as
 select mr_name,count(bigram) as count
  from have as a left join bigram as b
   on mr_name contains strip(bigram)
    group by mr_name;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Dec 2018 13:21:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/check-for-list-of-strings-within-a-character-variable-and-output/m-p/522851#M4528</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-12-20T13:21:53Z</dc:date>
    </item>
    <item>
      <title>Re: check for list of strings within a character variable and output count</title>
      <link>https://communities.sas.com/t5/New-SAS-User/check-for-list-of-strings-within-a-character-variable-and-output/m-p/522872#M4535</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input mr_name $19.;
cards;
cxhimgqabout
lolfvchickbznicefx
howmefvtoldbqcv
toldyounothing
;
run;

data bigram;
input bigram $;
cards;
bq
bz
cf
cj
cv
cx
fq
fv
fx
fz
gq
;
run;

data want(drop=bigram);
if _n_=1 then do;
	if 0 then set bigram;
   dcl hash H (dataset:'bigram') ;
   h.definekey  ("bigram") ;
   h.definedata ("bigram") ;
   h.definedone () ;
   dcl hiter hh('h');
end;
set have;
do while(hh.next()=0);
count=sum(count,count(mr_name,strip(bigram)));
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Dec 2018 14:31:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/check-for-list-of-strings-within-a-character-variable-and-output/m-p/522872#M4535</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-12-20T14:31:54Z</dc:date>
    </item>
  </channel>
</rss>

