<?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: Selecting cases based on all cells from another table in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Selecting-cases-based-on-all-cells-from-another-table/m-p/454366#M114840</link>
    <description>&lt;P&gt;Thank you Reeza,&lt;/P&gt;
&lt;P&gt;I fully agree that there should be certain rules enforced. However, in my example the only thing the users are allowed to do is to add rows/columns, and I believe this could be accounted for by the right code&lt;/P&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;AM&lt;/P&gt;</description>
    <pubDate>Mon, 16 Apr 2018 07:52:39 GMT</pubDate>
    <dc:creator>ammarhm</dc:creator>
    <dc:date>2018-04-16T07:52:39Z</dc:date>
    <item>
      <title>Selecting cases based on all cells from another table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-cases-based-on-all-cells-from-another-table/m-p/454316#M114819</link>
      <description>&lt;P&gt;Hi everyone.&lt;/P&gt;
&lt;P&gt;I have a table (&lt;STRONG&gt;have&lt;/STRONG&gt;)&amp;nbsp; containing millions of entries with ICD code diagnosis.&lt;/P&gt;
&lt;P&gt;I also have a table (&lt;STRONG&gt;ICD10&lt;/STRONG&gt;) which contains some ICD codes of interest:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data ICD10;&lt;BR /&gt;input L1:$ L2:$ L3:$ ;&lt;BR /&gt;datalines;&lt;BR /&gt;%F70 %E16% %G12%&lt;BR /&gt;%F71 %E17% .&lt;BR /&gt;%F72 %E18% %H4%&lt;BR /&gt;%F73 %E19% .&lt;BR /&gt;%F74% %E76% .&lt;BR /&gt;&lt;BR /&gt;run;&lt;/PRE&gt;
&lt;P&gt;This table (ICD10) is made ion a such a way that the end use will be able to modify it, so that it could contain any number of columns and rows&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I am trying to go is to create a code that would extract cases from (have) based on ICD10. At first, i thought it would be a very straigt forward proc SQl&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc SQL;
create table want as
select *&lt;BR /&gt;from have&lt;BR /&gt;where icd like (select * from icd10)&lt;BR /&gt;;&lt;BR /&gt;quit&lt;BR /&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Of course SAS was not happy to proceed as it expected a list of strings rather that what the&amp;nbsp;(select * from icd10) returned.&lt;/P&gt;
&lt;P&gt;I also considered joining the tables based on L1, L... but it proved to be difficult to create a generic code that would work. Remember the ICD10 table is user defined, so it could contain L1:L3 or L1:l10 column so I dont know in advance the number of columns (or rows) in the ICD10 table.&lt;/P&gt;
&lt;P&gt;Could anyone suggest a solution please? One way I am considering is to "melt" table ICD10 into a along string but haven't worked that out yet..&lt;/P&gt;
&lt;P&gt;All suggestions are appreciated&lt;/P&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;AM&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 15 Apr 2018 23:23:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-cases-based-on-all-cells-from-another-table/m-p/454316#M114819</guid>
      <dc:creator>ammarhm</dc:creator>
      <dc:date>2018-04-15T23:23:56Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting cases based on all cells from another table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-cases-based-on-all-cells-from-another-table/m-p/454322#M114823</link>
      <description>&lt;P&gt;You could transpose all your values of ICD10 to one column in a temporary dataset and run your proc sql.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc transpose data=ICD10 out=_ICD10;&lt;/P&gt;&lt;P&gt;var l:;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc transpose data=_ICD10 out=__ICD10;&lt;BR /&gt;by _name_;&lt;BR /&gt;var col:;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;proc&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;SQL&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
create &lt;SPAN class="token statement"&gt;table&lt;/SPAN&gt; want as
&lt;SPAN class="token statement"&gt;select&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;from&lt;/SPAN&gt; have where icd in &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token statement"&gt;select&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;transposed_column &lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;from&lt;/SPAN&gt; &lt;SPAN&gt;__ICD10&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;SPAN class="token procnames"&gt;quit&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Of course there are other approaches however I am feeling too lazy and tired to demo other approaches&lt;/P&gt;</description>
      <pubDate>Sun, 15 Apr 2018 23:52:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-cases-based-on-all-cells-from-another-table/m-p/454322#M114823</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-04-15T23:52:24Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting cases based on all cells from another table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-cases-based-on-all-cells-from-another-table/m-p/454324#M114825</link>
      <description>&lt;P&gt;Like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set ICD10 end=LASTOBS;
  array L (*) L1-L99 ;
  if _N_=1 then call execute('proc sql; create table WANT as select * from HAVE where');
  do I=1 to 99 ;
    if L[I] = ' ' then leave;
    if ADD_OR then call execute (' or ');
    ADD_OR+1;
    call execute(' ICD like ' || quote(trim(L[I]),"'") );
  end;
  if LASTOBS then call execute('; quit;');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;1 + proc sql;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;1 + create table WANT as select * from HAVE where&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;2 + ICD like '%F70'&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;3 + or&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;4 + ICD like '%E16%'&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;5 + or&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;6 + ICD like '%G12%'&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;7 + or&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;8 + ICD like '%F71'&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;9 + or&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;10 + ICD like '%E17%'&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;11 + or&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;12 + ICD like '%F72'&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;13 + or&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;14 + ICD like '%E18%'&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;15 + or&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;16 + ICD like '%H4%'&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;17 + or&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;18 + ICD like '%F73'&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;19 + or&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;20 + ICD like '%E19%'&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;21 + or&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;22 + ICD like '%F74%'&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;23 + or&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;24 + ICD like '%E76%'&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;25 + ;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Apr 2018 00:28:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-cases-based-on-all-cells-from-another-table/m-p/454324#M114825</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-04-16T00:28:44Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting cases based on all cells from another table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-cases-based-on-all-cells-from-another-table/m-p/454338#M114833</link>
      <description>&lt;P&gt;Enforce rules on your input otherwise you need your program to account for every single possible option - which is a bad idea.&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;This table (ICD10) is made ion a such a way that the end use will be able to modify it, so that it could contain any number of columns and rows&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Mon, 16 Apr 2018 03:19:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-cases-based-on-all-cells-from-another-table/m-p/454338#M114833</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-04-16T03:19:05Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting cases based on all cells from another table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-cases-based-on-all-cells-from-another-table/m-p/454366#M114840</link>
      <description>&lt;P&gt;Thank you Reeza,&lt;/P&gt;
&lt;P&gt;I fully agree that there should be certain rules enforced. However, in my example the only thing the users are allowed to do is to add rows/columns, and I believe this could be accounted for by the right code&lt;/P&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;AM&lt;/P&gt;</description>
      <pubDate>Mon, 16 Apr 2018 07:52:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-cases-based-on-all-cells-from-another-table/m-p/454366#M114840</guid>
      <dc:creator>ammarhm</dc:creator>
      <dc:date>2018-04-16T07:52:39Z</dc:date>
    </item>
  </channel>
</rss>

