<?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: Trying to find an efficient approach for identifying alphanumeric values in any one of 21 column in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-find-an-efficient-approach-for-identifying/m-p/799019#M314137</link>
    <description>&lt;P&gt;Thank you so much, Reeza.&amp;nbsp; Your reply was really helpful to me as a newer user.&amp;nbsp; I never would have figured out how to do this on my own with the books I have.&amp;nbsp; You also gave me new directions for learning, since I'm unfamiliar with flags and joining tables for this purpose. Thanks again for taking the time to write a helpful response with an explanation.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 27 Feb 2022 22:09:34 GMT</pubDate>
    <dc:creator>monstera</dc:creator>
    <dc:date>2022-02-27T22:09:34Z</dc:date>
    <item>
      <title>Trying to find an efficient approach for identifying alphanumeric values in any one of 21 columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-find-an-efficient-approach-for-identifying/m-p/799004#M314126</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to figure out the most efficient way to see if any one of several columns might contain an alphanumeric code of interest from a fairly long list. (Let's say my variables are called cause1-cause20 and death1.) The alphanumeric codes start with one letter and end with two or three numbers (e.g., X81, Y350, W19).&amp;nbsp; For the subsets I'm trying to create, I might be dealing with 50 or more different alphanumeric codes of interest.&amp;nbsp; Depending on the question being asked, the list may change, so I have to establish conditions for each subset.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For simpler situations using one variable (death1) for example, if I'm looking to see if my columns have a code in the range of W00 to W19, I approach it this way and there are no issues:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc sql;
	create table injury.deaths as
	select	&amp;amp;listx
	from	injury.deathfile
	where	death1 like 'W0%' or
		    death1 like 'W1%';
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;What would be an efficient approach when I have to search through several columns for instances of codes from a very long list of alphanumeric codes? Should I create macros for the list of codes? Is there a way to use wildcards or underscores in a macro?&amp;nbsp; Would I use an array and do loop and macros all at once? (I seem to get tripped up when combining things.)&amp;nbsp; Any advice would be greatly appreciated.&amp;nbsp; When I have experimented with arrays in data steps, I end up with all or none of the observations, which I know is incorrect.&amp;nbsp; Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using SAS x9.4.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 27 Feb 2022 20:45:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-find-an-efficient-approach-for-identifying/m-p/799004#M314126</guid>
      <dc:creator>monstera</dc:creator>
      <dc:date>2022-02-27T20:45:32Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to find an efficient approach for identifying alphanumeric values in any one of 21 column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-find-an-efficient-approach-for-identifying/m-p/799012#M314132</link>
      <description>&lt;P&gt;Use two arrays one for the list of values you want to check and one for list of variables to check. Use WHILE to shortcut the loop once you find a condition.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Untested:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;

array dx_want (3) _Temporary_ $8. ('Z123', 'Z185', 'Z245');
array dx_have(25) dx_prim dx2-dx25;
flag=0;

do i=1 to dim(dx_have) while(flag=0);
do j=1 to dim(dx_want) while(flag=0) ;
      if find( dx_have(i), dx_want(j))&amp;gt;0 then flag=1;
end;
end;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/418243"&gt;@monstera&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi everyone,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm trying to figure out the most efficient way to see if any one of several columns might contain an alphanumeric code of interest from a fairly long list. (Let's say my variables are called cause1-cause20 and death1.) The alphanumeric codes start with one letter and end with two or three numbers (e.g., X81, Y350, W19).&amp;nbsp; For the subsets I'm trying to create, I might be dealing with 50 or more different alphanumeric codes of interest.&amp;nbsp; Depending on the question being asked, the list may change, so I have to establish conditions for each subset.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For simpler situations using one variable (death1) for example, if I'm looking to see if my columns have a code in the range of W00 to W19, I approach it this way and there are no issues:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;proc sql;
	create table injury.deaths as
	select	&amp;amp;listx
	from	injury.deathfile
	where	death1 like 'W0%' or
		    death1 like 'W1%';
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;What would be an efficient approach when I have to search through several columns for instances of codes from a very long list of alphanumeric codes? Should I create macros for the list of codes? Is there a way to use wildcards or underscores in a macro?&amp;nbsp; Would I use an array and do loop and macros all at once? (I seem to get tripped up when combining things.)&amp;nbsp; Any advice would be greatly appreciated.&amp;nbsp; When I have experimented with arrays in data steps, I end up with all or none of the observations, which I know is incorrect.&amp;nbsp; Thank you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm using SAS x9.4.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Or you can also join with a column with like.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;proc sql;
	create table injury.deaths as
	select	&amp;amp;listx
	from	injury.deathfile&lt;BR /&gt;left join lookupTable as lt
	where	death1 like 'W0%' or
		    death1 like lt.variableCompare;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 27 Feb 2022 21:29:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-find-an-efficient-approach-for-identifying/m-p/799012#M314132</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-02-27T21:29:43Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to find an efficient approach for identifying alphanumeric values in any one of 21 column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-find-an-efficient-approach-for-identifying/m-p/799019#M314137</link>
      <description>&lt;P&gt;Thank you so much, Reeza.&amp;nbsp; Your reply was really helpful to me as a newer user.&amp;nbsp; I never would have figured out how to do this on my own with the books I have.&amp;nbsp; You also gave me new directions for learning, since I'm unfamiliar with flags and joining tables for this purpose. Thanks again for taking the time to write a helpful response with an explanation.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 27 Feb 2022 22:09:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-find-an-efficient-approach-for-identifying/m-p/799019#M314137</guid>
      <dc:creator>monstera</dc:creator>
      <dc:date>2022-02-27T22:09:34Z</dc:date>
    </item>
  </channel>
</rss>

