<?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: Combining tables with character and numeric columns in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Combining-tables-with-character-and-numeric-columns/m-p/523914#M142415</link>
    <description>&lt;P&gt;You need to fix your problem at the earliest stage, which is your import; at the moment it is very obviously NOT working, as it produces inconsistent results.&lt;/P&gt;
&lt;P&gt;ICD codes are&amp;nbsp;&lt;EM&gt;codes&lt;/EM&gt;, and as such are always stored as character, as you never do calculations with them, but only use them for grouping.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I repeat: use a sensible data format for the import (NOT Excel), and set correct types in your data step that reads the files.&lt;/P&gt;</description>
    <pubDate>Mon, 31 Dec 2018 07:17:05 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2018-12-31T07:17:05Z</dc:date>
    <item>
      <title>Combining tables with character and numeric columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-tables-with-character-and-numeric-columns/m-p/523741#M142333</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;
&lt;P&gt;I am trying to combine multiple tables (imported from excel) each of which contains ICD codes. Each table contains 2 columns: ICD_Code_column and ICD_Text_Column&lt;/P&gt;
&lt;P&gt;As you might know, the ICD 7, 8 and 9 codes are numerical, the ICD10 are character+numeric= character.&lt;/P&gt;
&lt;P&gt;So using a command like this causes an error:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data ICD;
set ICD6 ICD7 ICD8 ICD9;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The error being that the column containing the ICD code (&lt;SPAN&gt;ICD_Code_column&amp;nbsp;)&lt;/SPAN&gt; is defined both as numeric (in ICD7, ICD8, ICD9) and character (ICD10).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One way is to convert the numeric to character&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ICD7_character;
set ICD7(rename=(ICD_Code_column=x ));
length ICD_Code_column $6 ;
ICD_Code_column= put(x, 6.);
drop x;
run;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ICD8_character;
set ICD8(rename=(ICD_Code_column=x ));
length ICD_Code_column $6 ;
ICD_Code_column= put(x, 6.);
drop x;
run;&lt;BR /&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ICD9_character;
set ICD9(rename=(ICD_Code_column=x ));
length ICD_Code_column $6 ;
ICD_Code_column= put(x, 6.);
drop x;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;once all that is done then I can do&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data ICD;
set ICD7_character ICD8_character ICD9_character ICD10;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It does work, but does not look like an elegant solution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could anyone suggest a grammatically more efficient/ better solution? Using a macro or even a loop in Data - Set to combine all tables?&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Dec 2018 03:47:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-tables-with-character-and-numeric-columns/m-p/523741#M142333</guid>
      <dc:creator>ammarhm</dc:creator>
      <dc:date>2018-12-28T03:47:09Z</dc:date>
    </item>
    <item>
      <title>Re: Combining tables with character and numeric columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-tables-with-character-and-numeric-columns/m-p/523750#M142338</link>
      <description>&lt;P&gt;Save the Excel data to csv and import all tables with the same data step, and all your problems will be solved.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Dec 2018 08:44:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-tables-with-character-and-numeric-columns/m-p/523750#M142338</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-12-28T08:44:36Z</dc:date>
    </item>
    <item>
      <title>Re: Combining tables with character and numeric columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-tables-with-character-and-numeric-columns/m-p/523899#M142411</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;The import process works fine. The issue is that some ICD codes (ICD7-9) are numerical and are imported to SAS correctly as numerical while ICD 10 is a string variable and is imported as such\&lt;/P&gt;
&lt;P&gt;You cant set the 4 data files directly as variables are of different types, I was more looking into converting them to character variable in a simple way&lt;/P&gt;</description>
      <pubDate>Mon, 31 Dec 2018 00:16:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-tables-with-character-and-numeric-columns/m-p/523899#M142411</guid>
      <dc:creator>ammarhm</dc:creator>
      <dc:date>2018-12-31T00:16:40Z</dc:date>
    </item>
    <item>
      <title>Re: Combining tables with character and numeric columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-tables-with-character-and-numeric-columns/m-p/523914#M142415</link>
      <description>&lt;P&gt;You need to fix your problem at the earliest stage, which is your import; at the moment it is very obviously NOT working, as it produces inconsistent results.&lt;/P&gt;
&lt;P&gt;ICD codes are&amp;nbsp;&lt;EM&gt;codes&lt;/EM&gt;, and as such are always stored as character, as you never do calculations with them, but only use them for grouping.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I repeat: use a sensible data format for the import (NOT Excel), and set correct types in your data step that reads the files.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Dec 2018 07:17:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-tables-with-character-and-numeric-columns/m-p/523914#M142415</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-12-31T07:17:05Z</dc:date>
    </item>
    <item>
      <title>Re: Combining tables with character and numeric columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-tables-with-character-and-numeric-columns/m-p/523918#M142417</link>
      <description>&lt;P&gt;You can do this in a single datastep, e.g.:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ICD;
  set &lt;BR /&gt;    &lt;SPAN&gt;ICD7&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;rename&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;ICD_Code_column&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;x &lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;BR /&gt;    &lt;SPAN&gt;ICD8&lt;/SPAN&gt;(&lt;SPAN class="token function"&gt;rename&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;(&lt;SPAN&gt;ICD_Code_column&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;x &lt;/SPAN&gt;))&lt;BR /&gt;    &lt;SPAN&gt;ICD9&lt;/SPAN&gt;(&lt;SPAN class="token function"&gt;rename&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;(&lt;SPAN&gt;ICD_Code_column&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;x &lt;/SPAN&gt;))&lt;BR /&gt;    ICD10(in=ok)&lt;BR /&gt;    ;&lt;BR /&gt;  if not OK then&lt;BR /&gt;    &lt;SPAN&gt;ICD_Code_column&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;put&lt;/SPAN&gt;(&lt;SPAN&gt;x&lt;/SPAN&gt;, &lt;SPAN class="token number"&gt;6&lt;/SPAN&gt;.); &lt;BR /&gt;  &lt;SPAN class="token keyword"&gt;drop&lt;/SPAN&gt;&lt;SPAN&gt; x&lt;/SPAN&gt;; &lt;BR /&gt;&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 31 Dec 2018 09:49:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-tables-with-character-and-numeric-columns/m-p/523918#M142417</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2018-12-31T09:49:35Z</dc:date>
    </item>
    <item>
      <title>Re: Combining tables with character and numeric columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-tables-with-character-and-numeric-columns/m-p/523940#M142424</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/24798"&gt;@ammarhm&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi everyone,&lt;/P&gt;
&lt;P&gt;I am trying to combine multiple tables (imported from excel) each of which contains ICD codes. Each table contains 2 columns: ICD_Code_column and ICD_Text_Column&lt;/P&gt;
&lt;P&gt;As you might know, the ICD 7, 8 and 9 codes are numerical, the ICD10 are character+numeric= character.&lt;/P&gt;
&lt;P&gt;So using a command like this causes an error:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Actually, since the ICD codes have never been intended to use in arithmetic (what would the meaing of adding ICD codes 001 and 021 for&amp;nbsp; instance) they really should never be treated or considered numeric. The decimal values when used are showing subsets not numeric variation in the codes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I kind of cringe with the idea of having 4 different coding schemes in a single data set in a single variable.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Dec 2018 17:13:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-tables-with-character-and-numeric-columns/m-p/523940#M142424</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-12-31T17:13:13Z</dc:date>
    </item>
  </channel>
</rss>

