<?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: PROC SQL Joins &amp;amp; Time Formats in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/PROC-SQL-Joins-amp-Time-Formats/m-p/509328#M1764</link>
    <description>&lt;P&gt;Hi Kurt, Thanks for your reply! Yes, the time field was created from a DateTime field by using timepart(). Would this be why the join isn't happening properly? I have used this function in the past to create separate date and time fields and have never run across this problem before. &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 31 Oct 2018 20:50:05 GMT</pubDate>
    <dc:creator>sabataged</dc:creator>
    <dc:date>2018-10-31T20:50:05Z</dc:date>
    <item>
      <title>PROC SQL Joins &amp; Time Formats</title>
      <link>https://communities.sas.com/t5/New-SAS-User/PROC-SQL-Joins-amp-Time-Formats/m-p/509322#M1762</link>
      <description>&lt;P&gt;Hello everyone, I have run across a strange problem.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to join two tables that look something like this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Table "x"&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;Chat_ID&amp;nbsp; &amp;nbsp; xAge&amp;nbsp; &amp;nbsp; &amp;nbsp;xGender&amp;nbsp; &amp;nbsp; &amp;nbsp; xDate&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; xTime&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; 1236&amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;nbsp; &amp;nbsp; 21&amp;nbsp; &amp;nbsp; |&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;F&amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;nbsp; &amp;nbsp; &amp;nbsp;7/5/18&amp;nbsp; &amp;nbsp; |&amp;nbsp; &amp;nbsp;5:01PM&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; 2345&amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;nbsp; &amp;nbsp; 17&amp;nbsp; &amp;nbsp; |&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;M&amp;nbsp; &amp;nbsp; |&amp;nbsp; &amp;nbsp; &amp;nbsp;8/3/18&amp;nbsp; &amp;nbsp; |&amp;nbsp; &amp;nbsp;4:33PM&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Table "y"&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;Res_ID&amp;nbsp; &amp;nbsp; &amp;nbsp;yAge&amp;nbsp; &amp;nbsp; &amp;nbsp;yGender&amp;nbsp; &amp;nbsp; &amp;nbsp; yDate&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;yTime&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; 7708&amp;nbsp; &amp;nbsp; |&amp;nbsp; &amp;nbsp; 21&amp;nbsp; &amp;nbsp; |&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;F&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;nbsp; &amp;nbsp; &amp;nbsp;7/5/18&amp;nbsp; &amp;nbsp; |&amp;nbsp; &amp;nbsp;5:01PM&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; 7707&amp;nbsp; &amp;nbsp; |&amp;nbsp; &amp;nbsp; 17&amp;nbsp; &amp;nbsp; |&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;M&amp;nbsp; &amp;nbsp; &amp;nbsp; |&amp;nbsp; &amp;nbsp; &amp;nbsp;8/3/18&amp;nbsp; &amp;nbsp; |&amp;nbsp; &amp;nbsp;4:33PM&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;For example, Chat_ID 1236 and Res_ID 7708 are describing the same person, and must be joined by matching age, gender, and time.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I am trying to join them using this code:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql; 
create table Join1 as 
select x.*, y.* from x
inner join y on 
x.xdate=y.ydate and
x.xtime=y.ytime and
x.xage=y.yage and 
x.xgender=y.ygender
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; Under normal circumnstances, this code works, but I am getting 0 joins right now. After doing some troubleshooting, I realized that the "xtime" variable may be the culprit. I took away all the time formats to look at the raw SAS Time format:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;For&amp;nbsp;example, the time "5:12 PM" is written as 1.8201E9 in table x, but written as 61920 as table y. Why might this be? I think this discrepancy is the reason for why my tables aren't getting joined, but I'm not sure how to fix it.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Notes&lt;/STRONG&gt;:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;These datasets were imported from Excel via proc import.&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;The time in table "x" was created by separating the time from a "DateTime" field&lt;/LI&gt;&lt;LI&gt;Then I used "intnx" function to round the time to the nearest minute.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;I don't know if these things caused a difference, but I thought I would mention them! I did this to other datasets before, but never had this problem in the past, so I'm not sure what happened.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks in advance!!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Oct 2018 20:44:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/PROC-SQL-Joins-amp-Time-Formats/m-p/509322#M1762</guid>
      <dc:creator>sabataged</dc:creator>
      <dc:date>2018-10-31T20:44:36Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL Joins &amp; Time Formats</title>
      <link>https://communities.sas.com/t5/New-SAS-User/PROC-SQL-Joins-amp-Time-Formats/m-p/509327#M1763</link>
      <description>&lt;P&gt;Looks like one is a time value (seconds from midnight) and the other a datetime (seconds from midnight on 1960-01-01).&lt;/P&gt;</description>
      <pubDate>Wed, 31 Oct 2018 20:43:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/PROC-SQL-Joins-amp-Time-Formats/m-p/509327#M1763</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-10-31T20:43:50Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL Joins &amp; Time Formats</title>
      <link>https://communities.sas.com/t5/New-SAS-User/PROC-SQL-Joins-amp-Time-Formats/m-p/509328#M1764</link>
      <description>&lt;P&gt;Hi Kurt, Thanks for your reply! Yes, the time field was created from a DateTime field by using timepart(). Would this be why the join isn't happening properly? I have used this function in the past to create separate date and time fields and have never run across this problem before. &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Oct 2018 20:50:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/PROC-SQL-Joins-amp-Time-Formats/m-p/509328#M1764</guid>
      <dc:creator>sabataged</dc:creator>
      <dc:date>2018-10-31T20:50:05Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL Joins &amp; Time Formats</title>
      <link>https://communities.sas.com/t5/New-SAS-User/PROC-SQL-Joins-amp-Time-Formats/m-p/509335#M1766</link>
      <description>&lt;P&gt;The join condition&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;round(timepart(x.xtime), '00:01:00't) = round(y.ytime, '00:01:00't)&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;should work.&lt;/P&gt;</description>
      <pubDate>Wed, 31 Oct 2018 21:06:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/PROC-SQL-Joins-amp-Time-Formats/m-p/509335#M1766</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-10-31T21:06:49Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL Joins &amp; Time Formats</title>
      <link>https://communities.sas.com/t5/New-SAS-User/PROC-SQL-Joins-amp-Time-Formats/m-p/509345#M1770</link>
      <description>&lt;P&gt;Oh my goodness, this worked like a charm!&amp;nbsp; Thank you so much for your help!&amp;nbsp; I appreciate it a lot. I was stuck on this for a loooong time today. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Oct 2018 21:17:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/PROC-SQL-Joins-amp-Time-Formats/m-p/509345#M1770</guid>
      <dc:creator>sabataged</dc:creator>
      <dc:date>2018-10-31T21:17:45Z</dc:date>
    </item>
  </channel>
</rss>

