<?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: Including character inputs in a variable. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Including-character-inputs-in-a-variable/m-p/592174#M169757</link>
    <description>&lt;P&gt;Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/291673"&gt;@cool1993&lt;/a&gt;&amp;nbsp; Will this work?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
infile cards expandtabs truncover;
input NAME $	YEAR	CHAR1 &amp;amp; $10.	CHAR2  &amp;amp; $10.;
cards;
JOY	2009	A, B, C, D	  A, B, D
JOY	2009	A, B, D	A, B,  D
JOY	2010	A, D	A, B, D
JOY	2011	A, B, C, D	  B
;


data want;
set have;
include=countw(char2,', ')=countc(compress(char1,', '),compress(char2,','));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 27 Sep 2019 14:27:56 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2019-09-27T14:27:56Z</dc:date>
    <item>
      <title>Including character inputs in a variable.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Including-character-inputs-in-a-variable/m-p/592170#M169754</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to determine whether CHAR2 variable is included in CHAR1 variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The data and the desired results are as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&l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;&lt;TR&gt;&lt;TD&gt;JOY&lt;/TD&gt;&lt;TD&gt;2009&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;JOY&lt;/TD&gt;&lt;TD&gt;2009&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried the following solution, but it doesn't apply because the order of input is different.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;INCLUDE = (indexw(CHAR1,CHAR2,', ')&amp;gt;0);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;If you know the solution, please help me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Sep 2019 14:14:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Including-character-inputs-in-a-variable/m-p/592170#M169754</guid>
      <dc:creator>cool1993</dc:creator>
      <dc:date>2019-09-27T14:14:32Z</dc:date>
    </item>
    <item>
      <title>Re: Including character inputs in a variable.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Including-character-inputs-in-a-variable/m-p/592173#M169756</link>
      <description>&lt;P&gt;So it looks like you don't want to test if the value of CHAR2 is in CHAR1 (which is sort of what that function did).&lt;/P&gt;
&lt;P&gt;Instead it looks like you want to test if every item listed in in CHAR2 is also listed in CHAR1.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To do that you will need a loop.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  set have ;
  not_found=0;
  do i=1 to countw(char2,', ') until (not_found);
    not_found=not indexw(scan(char2,i,', '),char1);
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So for each record NOT_FOUND will be TRUE (have a value of 1) if there exists a word in CHAR2 that is NOT in CHAR1.&amp;nbsp; If ALL of words in CHAR2 are also in CHAR1 (or CHAR2 is empty) then NOT_FOUND will be FALSE (have a value of 0).&lt;/P&gt;</description>
      <pubDate>Fri, 27 Sep 2019 14:35:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Including-character-inputs-in-a-variable/m-p/592173#M169756</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-09-27T14:35:47Z</dc:date>
    </item>
    <item>
      <title>Re: Including character inputs in a variable.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Including-character-inputs-in-a-variable/m-p/592174#M169757</link>
      <description>&lt;P&gt;Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/291673"&gt;@cool1993&lt;/a&gt;&amp;nbsp; Will this work?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
infile cards expandtabs truncover;
input NAME $	YEAR	CHAR1 &amp;amp; $10.	CHAR2  &amp;amp; $10.;
cards;
JOY	2009	A, B, C, D	  A, B, D
JOY	2009	A, B, D	A, B,  D
JOY	2010	A, D	A, B, D
JOY	2011	A, B, C, D	  B
;


data want;
set have;
include=countw(char2,', ')=countc(compress(char1,', '),compress(char2,','));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 27 Sep 2019 14:27:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Including-character-inputs-in-a-variable/m-p/592174#M169757</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-09-27T14:27:56Z</dc:date>
    </item>
    <item>
      <title>Re: Including character inputs in a variable.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Including-character-inputs-in-a-variable/m-p/592178#M169760</link>
      <description>&lt;P&gt;Both CHAR1 and CHAR2 variables are strings that include &lt;STRONG&gt;lists&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;Are the lists of characters (1 byte each) or list of strings ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use function COUNTW to check how many members are in each of those variables,&lt;/P&gt;
&lt;P&gt;select a member of the list to check using SCAN function,&lt;/P&gt;
&lt;P&gt;Use DO loops to check each member of CHAR2, does it exist in CHAR1.&lt;/P&gt;
&lt;P&gt;You can check existence using either FINDW function or INDEX function or compare two members selected by SCAN.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Sep 2019 14:37:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Including-character-inputs-in-a-variable/m-p/592178#M169760</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2019-09-27T14:37:27Z</dc:date>
    </item>
  </channel>
</rss>

