<?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 sql merge in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/sql-merge/m-p/586796#M167510</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am getting 0 rows as output with no errors&amp;nbsp;&lt;/P&gt;&lt;P&gt;i think it is to do with the last condition i added re inst_no both are in character format&lt;/P&gt;&lt;P&gt;do i need to put them as numeric?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;227 create table EVTwNACRS as&lt;BR /&gt;228 select a.CIHI_key as CIHI_KEY_NAC,a.reg_dt, a.Reg_tm,a.Facility_NO as Facility_NAC, a.INST_NO as INST_AM,&lt;BR /&gt;229 a.ARRIVAL_DT, a.ARRIVAL_TM, b.CIHI_KEY as CIHI_KEY_DAD,a.FLAG_SP340_NACRS,a.sp340NACRS, b.Fiscal_QTR,b.EVT_INST_AMnew, b.EVT_INST_ATnew,&lt;BR /&gt;229! b.EVT_INST_NAMEnew,b.ADM_DT, b.ADM_TM, b.SP440,b.SP340,b.FLAG_SP440,b.flag_SP340, b.EVT_TM,&lt;BR /&gt;230 b.Facility_NO as Facility_DAD , b.HCNE as HCN_SP440,b.diag_code_01,b.diag_code_02,b.diag_code_03,b.diag_code_04,b.diag_code_05,b.diag_code_06,b.diag_code_07,&lt;BR /&gt;231 b.diag_code_08,b.diag_code_09,b.diag_code_10,b.diag_code_11,b.diag_code_12,b.diag_code_13,b.diag_code_14,b.diag_code_15,b.diag_code_16,b.diag_code_17,b.diag_code_1&lt;BR /&gt;231! 8,b.diag_code_19,b.diag_code_20,b.diag_code_21,b.diag_code_22,b.diag_code_23,b.diag_code_24,b.diag_code_25,b.diag_type_01,b.diag_type_02,b.diag_type_03,b.diag_type&lt;BR /&gt;231! _04,&lt;BR /&gt;232 b.diag_type_05,b.diag_type_06,b.diag_type_07,b.diag_type_08,b.diag_type_09,b.diag_type_10,b.diag_type_11,b.diag_type_12,b.diag_type_13,b.diag_type_14,b.diag_type_1&lt;BR /&gt;232! 5,b.diag_type_16,b.diag_type_17,b.diag_type_18,b.diag_type_19,b.diag_type_20,b.diag_type_21,b.diag_type_22,b.diag_type_23,b.diag_type_24,b.diag_type_25&lt;BR /&gt;233 from NAC_FY1718_emerg as a inner join EVTwInstn as b&lt;BR /&gt;234 on a.HCNE=b.HCNE&lt;BR /&gt;235 and 0&amp;lt;=datepart(b.ADM_DT)-datepart(a.Reg_DT)&amp;lt;=1 and&lt;BR /&gt;236 a.INST_NO=b.EVT_INST_AMnew&lt;BR /&gt;237 ;&lt;BR /&gt;NOTE: Table WORK.EVTWNACRS created, with 0 rows and 73 columns.&lt;/P&gt;&lt;P&gt;238 quit;&lt;BR /&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;BR /&gt;real time 0.04 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 06 Sep 2019 15:32:27 GMT</pubDate>
    <dc:creator>Ranjeeta</dc:creator>
    <dc:date>2019-09-06T15:32:27Z</dc:date>
    <item>
      <title>sql merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sql-merge/m-p/586796#M167510</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am getting 0 rows as output with no errors&amp;nbsp;&lt;/P&gt;&lt;P&gt;i think it is to do with the last condition i added re inst_no both are in character format&lt;/P&gt;&lt;P&gt;do i need to put them as numeric?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;227 create table EVTwNACRS as&lt;BR /&gt;228 select a.CIHI_key as CIHI_KEY_NAC,a.reg_dt, a.Reg_tm,a.Facility_NO as Facility_NAC, a.INST_NO as INST_AM,&lt;BR /&gt;229 a.ARRIVAL_DT, a.ARRIVAL_TM, b.CIHI_KEY as CIHI_KEY_DAD,a.FLAG_SP340_NACRS,a.sp340NACRS, b.Fiscal_QTR,b.EVT_INST_AMnew, b.EVT_INST_ATnew,&lt;BR /&gt;229! b.EVT_INST_NAMEnew,b.ADM_DT, b.ADM_TM, b.SP440,b.SP340,b.FLAG_SP440,b.flag_SP340, b.EVT_TM,&lt;BR /&gt;230 b.Facility_NO as Facility_DAD , b.HCNE as HCN_SP440,b.diag_code_01,b.diag_code_02,b.diag_code_03,b.diag_code_04,b.diag_code_05,b.diag_code_06,b.diag_code_07,&lt;BR /&gt;231 b.diag_code_08,b.diag_code_09,b.diag_code_10,b.diag_code_11,b.diag_code_12,b.diag_code_13,b.diag_code_14,b.diag_code_15,b.diag_code_16,b.diag_code_17,b.diag_code_1&lt;BR /&gt;231! 8,b.diag_code_19,b.diag_code_20,b.diag_code_21,b.diag_code_22,b.diag_code_23,b.diag_code_24,b.diag_code_25,b.diag_type_01,b.diag_type_02,b.diag_type_03,b.diag_type&lt;BR /&gt;231! _04,&lt;BR /&gt;232 b.diag_type_05,b.diag_type_06,b.diag_type_07,b.diag_type_08,b.diag_type_09,b.diag_type_10,b.diag_type_11,b.diag_type_12,b.diag_type_13,b.diag_type_14,b.diag_type_1&lt;BR /&gt;232! 5,b.diag_type_16,b.diag_type_17,b.diag_type_18,b.diag_type_19,b.diag_type_20,b.diag_type_21,b.diag_type_22,b.diag_type_23,b.diag_type_24,b.diag_type_25&lt;BR /&gt;233 from NAC_FY1718_emerg as a inner join EVTwInstn as b&lt;BR /&gt;234 on a.HCNE=b.HCNE&lt;BR /&gt;235 and 0&amp;lt;=datepart(b.ADM_DT)-datepart(a.Reg_DT)&amp;lt;=1 and&lt;BR /&gt;236 a.INST_NO=b.EVT_INST_AMnew&lt;BR /&gt;237 ;&lt;BR /&gt;NOTE: Table WORK.EVTWNACRS created, with 0 rows and 73 columns.&lt;/P&gt;&lt;P&gt;238 quit;&lt;BR /&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;BR /&gt;real time 0.04 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Sep 2019 15:32:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sql-merge/m-p/586796#M167510</guid>
      <dc:creator>Ranjeeta</dc:creator>
      <dc:date>2019-09-06T15:32:27Z</dc:date>
    </item>
    <item>
      <title>Re: sql merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sql-merge/m-p/586808#M167514</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/240770"&gt;@Ranjeeta&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I am getting 0 rows as output with no errors&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i think it is to do with the last condition i added re inst_no both are in character format&lt;/P&gt;
&lt;P&gt;do i need to put them as numeric?&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Are you referring to this part of your code?&lt;/P&gt;
&lt;PRE&gt; a.INST_NO=b.EVT_INST_AMne&lt;/PRE&gt;
&lt;P&gt;If both values are character then a common issue for not matching is capitalization. "Bob" is not equat to "bob". If that might be the case with your data then perhaps this may help.&lt;/P&gt;
&lt;PRE&gt;upcase( a.INST_NO) = upcase(b.EVT_INST_AMne)&lt;/PRE&gt;
&lt;P&gt;Another potential issue is leading spaces:&amp;nbsp; "&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bob" is not equal to "bob". The STRIP function can be used to remove such spaces in the comparison&lt;/P&gt;
&lt;PRE&gt;strip (upcase( a.INST_NO)) = strip(upcase(b.EVT_INST_AMne))&lt;/PRE&gt;
&lt;P&gt;Other comparisons than = would be needed if you are looking to match part of one character value with another.&lt;/P&gt;
&lt;P&gt;But we don't have any of your data to say specifically why you get no results.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Sep 2019 16:27:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sql-merge/m-p/586808#M167514</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-09-06T16:27:16Z</dc:date>
    </item>
    <item>
      <title>Re: sql merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sql-merge/m-p/586855#M167526</link>
      <description>&lt;P&gt;What kind of numbers are a.INST_NO and b.EVT_INST_AMnew? If integers, then the problem is probably elsewhere. But if real numbers, they might need rounding to match.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Sep 2019 19:43:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sql-merge/m-p/586855#M167526</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-09-06T19:43:46Z</dc:date>
    </item>
  </channel>
</rss>

