<?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: Find a value in all columns of a table in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Find-a-value-in-all-columns-of-a-table/m-p/793188#M254190</link>
    <description>&lt;P&gt;what if the value is a number and the variable is character.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a situation where i should find a number ''4543" in nearly 150 variables. variables are mixed of numeric and char.&amp;nbsp;&lt;/P&gt;&lt;P&gt;could you please suggest&lt;/P&gt;</description>
    <pubDate>Fri, 28 Jan 2022 18:53:12 GMT</pubDate>
    <dc:creator>manojb</dc:creator>
    <dc:date>2022-01-28T18:53:12Z</dc:date>
    <item>
      <title>Find a value in all columns of a table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-a-value-in-all-columns-of-a-table/m-p/753288#M237389</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;is there a simple&amp;nbsp; technique to find all records in a table where a specific value existe in one or more column?&lt;/P&gt;&lt;P&gt;For example, I want to retreive all records from table "tab" where we have "HL"&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;data tab;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;input num1 num2 char1 $ num3 char2 $ char3 $;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;datalines;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;1 2 HL 3 HL X&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;4 5 AA 6 HL Y&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;7 8 EE 9 DD Z&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;run;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;out put ==&amp;gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;1 2 HL 3 HL X&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;4 5 AA 6 HL Y&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Thx,&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jul 2021 21:08:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-a-value-in-all-columns-of-a-table/m-p/753288#M237389</guid>
      <dc:creator>viona</dc:creator>
      <dc:date>2021-07-09T21:08:47Z</dc:date>
    </item>
    <item>
      <title>Re: Find a value in all columns of a table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-a-value-in-all-columns-of-a-table/m-p/753289#M237390</link>
      <description>&lt;P&gt;Since HL can only exist in character variables, we only search the character variables. I will use the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p0jfvenvsqk24vn1q2ypospoq9ij.htm" target="_self"&gt;WHICHC function&lt;/A&gt; to do the searching.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set tab;
    if whichc('HL',of char:)&amp;gt;0 then output;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now, you made it easy, your character variable names all begin with the four letters char. If that's not the case in your real data, and you have character variables named GORILLA, SWAN, OCTOPUS, and so on, then instead of typing them all out, you could use something like this to search all character variables, regardless of their name:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if whichc('HL',of _character_)&amp;gt;0 then output;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jul 2021 21:32:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-a-value-in-all-columns-of-a-table/m-p/753289#M237390</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-07-09T21:32:30Z</dc:date>
    </item>
    <item>
      <title>Re: Find a value in all columns of a table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-a-value-in-all-columns-of-a-table/m-p/753298#M237392</link>
      <description>Thx a lot this is really helpful.</description>
      <pubDate>Fri, 09 Jul 2021 22:48:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-a-value-in-all-columns-of-a-table/m-p/753298#M237392</guid>
      <dc:creator>viona</dc:creator>
      <dc:date>2021-07-09T22:48:18Z</dc:date>
    </item>
    <item>
      <title>Re: Find a value in all columns of a table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-a-value-in-all-columns-of-a-table/m-p/793188#M254190</link>
      <description>&lt;P&gt;what if the value is a number and the variable is character.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a situation where i should find a number ''4543" in nearly 150 variables. variables are mixed of numeric and char.&amp;nbsp;&lt;/P&gt;&lt;P&gt;could you please suggest&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jan 2022 18:53:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-a-value-in-all-columns-of-a-table/m-p/793188#M254190</guid>
      <dc:creator>manojb</dc:creator>
      <dc:date>2022-01-28T18:53:12Z</dc:date>
    </item>
  </channel>
</rss>

