<?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 join 2 tables linking on a character variable where they are 2 different lengths in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/trying-to-join-2-tables-linking-on-a-character-variable-where/m-p/739242#M28937</link>
    <description>&lt;P&gt;If you use SQL to join you can match on function results.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the strings are just digit strings of less 16 characters then just convert both to numbers and match the numbers.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select *
from table1 
inner join table2
on input(table1.id,32.) = input(table2.id,32.)
;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 05 May 2021 15:52:24 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2021-05-05T15:52:24Z</dc:date>
    <item>
      <title>trying to join 2 tables linking on a character variable where they are 2 different lengths</title>
      <link>https://communities.sas.com/t5/New-SAS-User/trying-to-join-2-tables-linking-on-a-character-variable-where/m-p/739233#M28935</link>
      <description>&lt;P&gt;I am trying to link on a character field but 1 table the character is 3 digits and the other it is 4 digits. I was going to add a leading zero to the 3 digits but I can only see how to use the z function with numbers not characters. I think I need to use a right conc function but I can't figure out how to make that join.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 May 2021 15:32:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/trying-to-join-2-tables-linking-on-a-character-variable-where/m-p/739233#M28935</guid>
      <dc:creator>ljw4</dc:creator>
      <dc:date>2021-05-05T15:32:07Z</dc:date>
    </item>
    <item>
      <title>Re: trying to join 2 tables linking on a character variable where they are 2 different lengths</title>
      <link>https://communities.sas.com/t5/New-SAS-User/trying-to-join-2-tables-linking-on-a-character-variable-where/m-p/739240#M28936</link>
      <description>if length(variable) = 3 then variable = catt("0", variable);&lt;BR /&gt;</description>
      <pubDate>Wed, 05 May 2021 15:46:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/trying-to-join-2-tables-linking-on-a-character-variable-where/m-p/739240#M28936</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-05-05T15:46:40Z</dc:date>
    </item>
    <item>
      <title>Re: trying to join 2 tables linking on a character variable where they are 2 different lengths</title>
      <link>https://communities.sas.com/t5/New-SAS-User/trying-to-join-2-tables-linking-on-a-character-variable-where/m-p/739242#M28937</link>
      <description>&lt;P&gt;If you use SQL to join you can match on function results.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the strings are just digit strings of less 16 characters then just convert both to numbers and match the numbers.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select *
from table1 
inner join table2
on input(table1.id,32.) = input(table2.id,32.)
;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 05 May 2021 15:52:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/trying-to-join-2-tables-linking-on-a-character-variable-where/m-p/739242#M28937</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-05-05T15:52:24Z</dc:date>
    </item>
    <item>
      <title>Re: trying to join 2 tables linking on a character variable where they are 2 different lengths</title>
      <link>https://communities.sas.com/t5/New-SAS-User/trying-to-join-2-tables-linking-on-a-character-variable-where/m-p/739246#M28938</link>
      <description>Thank you. Where do I put this in my code? This is my code below&lt;BR /&gt;&lt;BR /&gt;PROC SQL;&lt;BR /&gt;CREATE TABLE MSDRG_table AS&lt;BR /&gt;SELECT t1.MSDRG,&lt;BR /&gt;t1.DischargeFiscalYearNBR,&lt;BR /&gt;t1.MSDRGMajorDiagnosticCategoryCD,&lt;BR /&gt;t1.MSDRGTypeCD,&lt;BR /&gt;t1.MSDRGDSC,&lt;BR /&gt;t1.MSDRGWeightNBR,&lt;BR /&gt;t1.MSDRGeometricMeanLengthOfStayNBR,&lt;BR /&gt;t1.RowStatusDSC,&lt;BR /&gt;t1.CreateDTS,&lt;BR /&gt;t1.UpdateDTS,&lt;BR /&gt;t1.MSDRGAverageLengthOfStayNBR,&lt;BR /&gt;t1.EDWLastModifiedDTS,&lt;BR /&gt;if length(MSDRG) = 3 then variable = catt("0", MSDRG)&lt;BR /&gt;&lt;BR /&gt;FROM ANALYTIC.MSDRG t1&lt;BR /&gt;WHERE t1.DischargeFiscalYearNBR = 2019;&lt;BR /&gt;QUIT;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 05 May 2021 16:01:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/trying-to-join-2-tables-linking-on-a-character-variable-where/m-p/739246#M28938</guid>
      <dc:creator>ljw4</dc:creator>
      <dc:date>2021-05-05T16:01:57Z</dc:date>
    </item>
    <item>
      <title>Re: trying to join 2 tables linking on a character variable where they are 2 different lengths</title>
      <link>https://communities.sas.com/t5/New-SAS-User/trying-to-join-2-tables-linking-on-a-character-variable-where/m-p/739248#M28939</link>
      <description>SQL requires CASE WHEN, not an IF statement. (There was no indication this was a SQL question that I could see).&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/sqlproc/n0a85s0ijz65irn1h3jtariooea5.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/sqlproc/n0a85s0ijz65irn1h3jtariooea5.htm&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Since you are using SQL, Tom's answer is more appropriate.</description>
      <pubDate>Wed, 05 May 2021 16:16:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/trying-to-join-2-tables-linking-on-a-character-variable-where/m-p/739248#M28939</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-05-05T16:16:14Z</dc:date>
    </item>
    <item>
      <title>Re: trying to join 2 tables linking on a character variable where they are 2 different lengths</title>
      <link>https://communities.sas.com/t5/New-SAS-User/trying-to-join-2-tables-linking-on-a-character-variable-where/m-p/739264#M28940</link>
      <description>&lt;P&gt;I am using SAS not SQL&lt;/P&gt;</description>
      <pubDate>Wed, 05 May 2021 16:29:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/trying-to-join-2-tables-linking-on-a-character-variable-where/m-p/739264#M28940</guid>
      <dc:creator>ljw4</dc:creator>
      <dc:date>2021-05-05T16:29:59Z</dc:date>
    </item>
    <item>
      <title>Re: trying to join 2 tables linking on a character variable where they are 2 different lengths</title>
      <link>https://communities.sas.com/t5/New-SAS-User/trying-to-join-2-tables-linking-on-a-character-variable-where/m-p/739272#M28943</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/354146"&gt;@ljw4&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am using SAS not SQL&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;In SAS to use SQL syntax you need to use it inside of PROC SQL step.&lt;/P&gt;
&lt;P&gt;Do you totally not want to use any SQL code?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you really must use data step to join the tables then you will need modify one or both of the variables.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data for_merge_one;
  set one;
  numid = input(id,32.);
run;
proc sort; by numid; run;
data for_merge_two;
  set two;
  numid=input(id,32.);
run;
proc sort; by numid; run;
data want;
  merge for_merge_one for_merge_two;
  by numid;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 05 May 2021 16:43:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/trying-to-join-2-tables-linking-on-a-character-variable-where/m-p/739272#M28943</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-05-05T16:43:13Z</dc:date>
    </item>
    <item>
      <title>Re: trying to join 2 tables linking on a character variable where they are 2 different lengths</title>
      <link>https://communities.sas.com/t5/New-SAS-User/trying-to-join-2-tables-linking-on-a-character-variable-where/m-p/739310#M28950</link>
      <description>This worked but my issue is I need a left join and when I use this with a&lt;BR /&gt;left join I'm still only getting results of an inner join. Does that make&lt;BR /&gt;sense?&lt;BR /&gt;</description>
      <pubDate>Wed, 05 May 2021 18:50:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/trying-to-join-2-tables-linking-on-a-character-variable-where/m-p/739310#M28950</guid>
      <dc:creator>ljw4</dc:creator>
      <dc:date>2021-05-05T18:50:57Z</dc:date>
    </item>
  </channel>
</rss>

