<?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 if one column contain at least one argument from another column in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Check-if-one-column-contain-at-least-one-argument-from-another/m-p/911795#M359517</link>
    <description>&lt;P&gt;Exactly what is the purpose of storing two or more values in a single variable? This violates principals of data normalization and generally leads to extremely hard to maintain code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And for further consideration is a value of "11,22" considered equal to "22,11"? See how quickly poor data adds to possibly confusion?&amp;nbsp; By the time you get to 11,22,33 you have to consider "equality" of 11,33,22 22,33,11 22,11,33 33,11,22 33,22,11 .&amp;nbsp; And what about the entirely too likely entry of occasional spaces embedded in the values such as "11, 22"? Is that to be considered equal to "11,22"? (A basic use of the = operator will return false.)&lt;/P&gt;</description>
    <pubDate>Wed, 17 Jan 2024 15:38:01 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2024-01-17T15:38:01Z</dc:date>
    <item>
      <title>Check if one column contain at least one argument from another column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-if-one-column-contain-at-least-one-argument-from-another/m-p/911745#M359509</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I have a data set with 2 string columns.&lt;/P&gt;
&lt;P&gt;I want to create a new column called Ind that will get value 2 or 1 or 0.&lt;/P&gt;
&lt;P&gt;IF column W doesn't contain&amp;nbsp; any argument of column X then value 0.&lt;/P&gt;
&lt;P&gt;If value of W contain at least one argument from column X&amp;nbsp; but W not equal to X then value 1.&lt;/P&gt;
&lt;P&gt;IF W=X&amp;nbsp; then value 2.&lt;/P&gt;
&lt;P&gt;What is the way to do it please?&lt;/P&gt;
&lt;P&gt;Please note that&amp;nbsp;&amp;nbsp;arguments are determined by delimiter comma&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One more condition is that if column X =Column W&lt;/P&gt;
&lt;PRE&gt;&lt;SPAN&gt;&lt;BR /&gt;Data have;&lt;BR /&gt;input X $ w $;&lt;BR /&gt;cards;&lt;BR /&gt;11,22 33&lt;BR /&gt;11,22 44&lt;BR /&gt;11,22 11&lt;BR /&gt;11,22 22 &lt;BR /&gt;11,22 11,22,66&lt;BR /&gt;;&lt;BR /&gt;run;&amp;nbsp;&lt;/SPAN&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 Jan 2024 12:13:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-if-one-column-contain-at-least-one-argument-from-another/m-p/911745#M359509</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2024-01-17T12:13:29Z</dc:date>
    </item>
    <item>
      <title>Re: Check if one column contain at least one argument from another column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-if-one-column-contain-at-least-one-argument-from-another/m-p/911760#M359510</link>
      <description>&lt;P&gt;Please test your code before posting. Please be sure it produces the desired data set. Testing your code is a good thing to do, and in my opinion, it is mandatory. Please don't make us test it or correct it for you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2024-01-17 05_52_39-SAS Studio — Mozilla Firefox.png" style="width: 278px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/92583i531E7B5524BC7892/image-size/large?v=v2&amp;amp;px=999" role="button" title="2024-01-17 05_52_39-SAS Studio — Mozilla Firefox.png" alt="2024-01-17 05_52_39-SAS Studio — Mozilla Firefox.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jan 2024 10:53:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-if-one-column-contain-at-least-one-argument-from-another/m-p/911760#M359510</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-01-17T10:53:56Z</dc:date>
    </item>
    <item>
      <title>Re: Check if one column contain at least one argument from another column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-if-one-column-contain-at-least-one-argument-from-another/m-p/911765#M359511</link>
      <description>&lt;P&gt;Sorry,raw data is&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
Data have;
input X $ w $;
cards;
11,22 33
11,22 44
11,22 11
11,22 22 
11,22 11,22,66
 ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 Jan 2024 12:12:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-if-one-column-contain-at-least-one-argument-from-another/m-p/911765#M359511</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2024-01-17T12:12:45Z</dc:date>
    </item>
    <item>
      <title>Re: Check if one column contain at least one argument from another column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-if-one-column-contain-at-least-one-argument-from-another/m-p/911766#M359512</link>
      <description>&lt;P&gt;Here is my code. I did not program the case where x=w, you did not give us an example in the data set, and I believe you can modify the code to handle this case without our help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    n_words_x=countw(x,',');
    n_words_w=countw(w,',');
    ind=0;
    do i=1 to n_words_x;
        do j=1 to n_words_w;
            if scan(x,i,',')=scan(w,j,',') then ind=1;
            leave;
        end;
    end;
    drop i j n_words:;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jan 2024 12:34:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-if-one-column-contain-at-least-one-argument-from-another/m-p/911766#M359512</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-01-17T12:34:04Z</dc:date>
    </item>
    <item>
      <title>Re: Check if one column contain at least one argument from another column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-if-one-column-contain-at-least-one-argument-from-another/m-p/911795#M359517</link>
      <description>&lt;P&gt;Exactly what is the purpose of storing two or more values in a single variable? This violates principals of data normalization and generally leads to extremely hard to maintain code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And for further consideration is a value of "11,22" considered equal to "22,11"? See how quickly poor data adds to possibly confusion?&amp;nbsp; By the time you get to 11,22,33 you have to consider "equality" of 11,33,22 22,33,11 22,11,33 33,11,22 33,22,11 .&amp;nbsp; And what about the entirely too likely entry of occasional spaces embedded in the values such as "11, 22"? Is that to be considered equal to "11,22"? (A basic use of the = operator will return false.)&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jan 2024 15:38:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-if-one-column-contain-at-least-one-argument-from-another/m-p/911795#M359517</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-01-17T15:38:01Z</dc:date>
    </item>
  </channel>
</rss>

