<?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: checking values within row in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/checking-values-within-row/m-p/332935#M74984</link>
    <description>&lt;P&gt;You want that character appeared at least twice in s1-s5 ?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dummy;
infile datalines missover;
input ID C1$ C2$ C3$ C4$ C5$ C6$ C7$ C8$ C9$ C10$ S1$ S2$ S3$ S4$ S5$;
datalines;
1234 a b . . . . . . . . b b d .
2235 b d a . . . . . . . a d a s
2568 a s d f g h i . . . x y z
2698 x x x . . . . . . . x x y z
5545 a x d f f f f f f f f s d f
5625 f k l a f . . . . . y t . . .
;
run;

data want;
 set dummy;
   array cx{*} $ c1-c10;
   array sx{*} $ s1-s10;
   do i=1 to dim(cx);
    n=countc(cats(of sx{*}),cx{i});
    if n gt 1 then do;output;leave;end;
   end;
drop i n;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 15 Feb 2017 10:31:26 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2017-02-15T10:31:26Z</dc:date>
    <item>
      <title>checking values within row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/checking-values-within-row/m-p/332905#M74976</link>
      <description>&lt;P&gt;Dear Consultants,&lt;/P&gt;&lt;P&gt;For the first time I used data step for creating dummy dataset(as I always get data in CSV files and never got a chance to use input statements), I hope now nobody will get anxious. Here is the dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data dummy;&lt;BR /&gt;infile datalines missover;&lt;BR /&gt;input ID C1$ C2$ C3$ C4$ C5$ C6$ C7$ C8$ C9$ C10$ S1$ S2$ S3$ S4$ S5$;&lt;BR /&gt;datalines;&lt;BR /&gt;1234 a b . . . . . . . . b b d .&lt;BR /&gt;2235 b d a . . . . . . . a d a s&lt;BR /&gt;2568 a s d f g h i . . . x y z&lt;BR /&gt;2698 x x x . . . . . . . x x y z&lt;BR /&gt;5545 a x d f f f f f f f f s d f&lt;BR /&gt;5625 f k l a f . . . . . y t . . .&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now from this dataset I want only those records in which values in columns C (C1 to C10) are repeated in columns S (S1 to S5), something like below.&lt;/P&gt;&lt;P&gt;1234 &amp;nbsp;a b . . . . . . . . b b d .&lt;BR /&gt;2235 &amp;nbsp;b d a . . . . . . . a d a s&lt;BR /&gt;2698 x x x . . . . . . . x x y z&lt;BR /&gt;5545 a x d f f f f f f f f s d f&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Waiting for the expert advise.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2017 05:13:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/checking-values-within-row/m-p/332905#M74976</guid>
      <dc:creator>deega</dc:creator>
      <dc:date>2017-02-15T05:13:24Z</dc:date>
    </item>
    <item>
      <title>Re: checking values within row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/checking-values-within-row/m-p/332910#M74977</link>
      <description>&lt;P&gt;Next code will do what you want:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dummy;
infile datalines missover;
input ID C1$ C2$ C3$ C4$ C5$ C6$ C7$ C8$ C9$ C10$ S1$ S2$ S3$ S4$ S5$;
datalines;
1234 a b . . . . . . . . b b d .
2235 b d a . . . . . . . a d a s
2568 a s d f g h i . . . x y z
2698 x x x . . . . . . . x x y z
5545 a x d f f f f f f f f s d f
5625 f k l a f . . . . . y t . . .
;
run;

data want;
 set dummy;
   array cx $ c1-c10;
   array sx $ s1-s10;
   flag=0;
   do i=1 to dim(cx);
      if cx(i) not in (' ','.') and&lt;BR /&gt;         whichc(cx(i),s1,s2,s3,s4,s5) then flag=1;
   end;
   if flag;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 Feb 2017 06:47:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/checking-values-within-row/m-p/332910#M74977</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-02-15T06:47:01Z</dc:date>
    </item>
    <item>
      <title>Re: checking values within row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/checking-values-within-row/m-p/332930#M74982</link>
      <description>only minor comment.....&lt;BR /&gt;The effect of the input statement would treat a value '.' as missing and replace it with blank. So, the IF CX(i) test needs check only for blank.&lt;BR /&gt;Only informat $CHAR returns the dots as a value.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 15 Feb 2017 09:32:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/checking-values-within-row/m-p/332930#M74982</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2017-02-15T09:32:59Z</dc:date>
    </item>
    <item>
      <title>Re: checking values within row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/checking-values-within-row/m-p/332935#M74984</link>
      <description>&lt;P&gt;You want that character appeared at least twice in s1-s5 ?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dummy;
infile datalines missover;
input ID C1$ C2$ C3$ C4$ C5$ C6$ C7$ C8$ C9$ C10$ S1$ S2$ S3$ S4$ S5$;
datalines;
1234 a b . . . . . . . . b b d .
2235 b d a . . . . . . . a d a s
2568 a s d f g h i . . . x y z
2698 x x x . . . . . . . x x y z
5545 a x d f f f f f f f f s d f
5625 f k l a f . . . . . y t . . .
;
run;

data want;
 set dummy;
   array cx{*} $ c1-c10;
   array sx{*} $ s1-s10;
   do i=1 to dim(cx);
    n=countc(cats(of sx{*}),cx{i});
    if n gt 1 then do;output;leave;end;
   end;
drop i n;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2017 10:31:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/checking-values-within-row/m-p/332935#M74984</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-02-15T10:31:26Z</dc:date>
    </item>
    <item>
      <title>Re: checking values within row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/checking-values-within-row/m-p/333001#M74996</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/88384"&gt;@Shmuel&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Minor efficiency comment.&amp;nbsp; Consider changing&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; do i&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt; to &lt;SPAN class="token function"&gt;dim&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;cx&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;to&lt;/P&gt;
&lt;P&gt;&amp;nbsp; do i&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt; to &lt;SPAN class="token function"&gt;dim&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;cx&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;) while (flag^=1);&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2017 13:37:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/checking-values-within-row/m-p/333001#M74996</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-02-15T13:37:43Z</dc:date>
    </item>
    <item>
      <title>Re: checking values within row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/checking-values-within-row/m-p/333039#M74999</link>
      <description>&lt;P&gt;Thanks to&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15174"&gt;@Peter_C&lt;/a&gt;&amp;nbsp;the ext code would be more efficient:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
 set dummy;
   array cx $ c1-c10;
   array sx $ s1-s10;
   flag=0;
   do i=1 to dim(cx) while flag = 0;
      if not missing(cx(i))  and       
         whichc(cx(i),s1,s2,s3,s4,s5) then flag=1;
   end;
   if flag;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 Feb 2017 15:07:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/checking-values-within-row/m-p/333039#M74999</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-02-15T15:07:47Z</dc:date>
    </item>
    <item>
      <title>Re: checking values within row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/checking-values-within-row/m-p/333303#M75074</link>
      <description>Thanks to &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/88384"&gt;@Shmuel&lt;/a&gt;&lt;BR /&gt;This program is giving desired solution with just a minor syntax error. flag = 0 → (flag=0)&lt;BR /&gt;</description>
      <pubDate>Thu, 16 Feb 2017 07:25:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/checking-values-within-row/m-p/333303#M75074</guid>
      <dc:creator>deega</dc:creator>
      <dc:date>2017-02-16T07:25:00Z</dc:date>
    </item>
  </channel>
</rss>

