<?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 issue - joining while creating a new variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-issue-joining-while-creating-a-new-variable/m-p/78352#M288138</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With your help I figured it out.&amp;nbsp; I didn't realize that the tables were organized by a different variable that also utilized the date variable so the join referenced both dates on the unseen variable.&amp;nbsp; &lt;/P&gt;&lt;P&gt;Thank you so much for your guidance.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;Regulator&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 28 Sep 2012 19:18:25 GMT</pubDate>
    <dc:creator>DasRegulator</dc:creator>
    <dc:date>2012-09-28T19:18:25Z</dc:date>
    <item>
      <title>PROC SQL issue - joining while creating a new variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-issue-joining-while-creating-a-new-variable/m-p/78346#M288132</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dumb Question:&lt;/P&gt;&lt;P&gt;I am currently facing an issue where the statement below confuses the dates when combining datasets.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG style="color: navy; background: white; font-size: 11.0pt; font-family: 'Courier New';"&gt;PROC&lt;/STRONG&gt; &lt;STRONG style="color: navy; background: white; font-size: 11.0pt; font-family: 'Courier New';"&gt;SQL&lt;/STRONG&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;CREATE&lt;/SPAN&gt; &lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;TABLE&lt;/SPAN&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; WORK.Three &lt;/SPAN&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;AS&lt;/SPAN&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;SELECT&lt;/SPAN&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; T1.TR_PRICE,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; T1.TR_QUANTITY,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; T1.DT_PK_QUANTITY,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; T1.DATE,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; T2.tot_dt_pk_quantity,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (TR_PRICE*(DT_PK_QUANTITY/tot_dt_pk_quantity)) &lt;/SPAN&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;AS&lt;/SPAN&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; TR_WEIGHTED_PRICE&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;FROM&lt;/SPAN&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; WORK.One T1, WORK.Two T2 &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;WHERE&lt;/SPAN&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; T1.DATE=T2.DATE&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;ORDER&lt;/SPAN&gt; &lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;BY&lt;/SPAN&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; T1.DATE;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG style="color: navy; background: white; font-size: 11.0pt; font-family: 'Courier New';"&gt;RUN&lt;/STRONG&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG style="color: navy; background: white; font-size: 11.0pt; font-family: 'Courier New';"&gt;QUIT&lt;/STRONG&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;In the T1 table, there are multiple values for the date (ex:40 lines of data for 01Jan2012), however in the T2 table there is only one value for the date.&amp;nbsp; Then when the new table is created, the variable DT_PK_Quantity takes the correct values for JAN 1-2, but then starts spitting out random numbers (half right, half wrong) for the variable.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There is no error statement, nor warning statement, just a confused table as the end product.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help would be most appreciated!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;Regulator&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Sep 2012 20:44:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-issue-joining-while-creating-a-new-variable/m-p/78346#M288132</guid>
      <dc:creator>DasRegulator</dc:creator>
      <dc:date>2012-09-26T20:44:58Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL issue - joining while creating a new variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-issue-joining-while-creating-a-new-variable/m-p/78347#M288133</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Have you tried using T1.TR_PRICE, T1.DT_PK_QUANTITY and T2.TOT_DT_PK_QUANTITY in the calculation?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also you may want&lt;/P&gt;&lt;P&gt;From WORK.ONE AS T LEFT JOIN WORK.TWO AS T2 ON T1.DATE=T2.DATE instead of your current From and WHERE clauses (guessing at what you are attempting to do).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Sep 2012 20:53:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-issue-joining-while-creating-a-new-variable/m-p/78347#M288133</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2012-09-26T20:53:44Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL issue - joining while creating a new variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-issue-joining-while-creating-a-new-variable/m-p/78348#M288134</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your join code looks pretty clean to me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is it possible that your two source tables have slightly different underlying formats for the dates, such that the readable version is equivalent, but the actual values aren't? (Like a SAS datetime value formatted to only show date).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That's all I can think of. What data management systems are the two tables in?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Sep 2012 21:09:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-issue-joining-while-creating-a-new-variable/m-p/78348#M288134</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2012-09-26T21:09:56Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL issue - joining while creating a new variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-issue-joining-while-creating-a-new-variable/m-p/78349#M288135</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If I put: (t1.tr_price*(t1.dt_pk_quantity/t2.&lt;SPAN style="color: #000000; font-family: 'Courier New'; font-size: 15px; background-color: #ffffff;"&gt;tot_dt_pk_quantity&lt;/SPAN&gt;)...&lt;/P&gt;&lt;P&gt;then I receive an error message.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'll try the Join statement and see what happens.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Sep 2012 15:30:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-issue-joining-while-creating-a-new-variable/m-p/78349#M288135</guid>
      <dc:creator>DasRegulator</dc:creator>
      <dc:date>2012-09-27T15:30:46Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL issue - joining while creating a new variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-issue-joining-while-creating-a-new-variable/m-p/78350#M288136</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tom,&lt;/P&gt;&lt;P&gt;When I saw your message, I really hoped that, that was the case, but unfortunately both formats are in DATE9.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, the files are SAS7bdat &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Sep 2012 15:35:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-issue-joining-while-creating-a-new-variable/m-p/78350#M288136</guid>
      <dc:creator>DasRegulator</dc:creator>
      <dc:date>2012-09-27T15:35:06Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL issue - joining while creating a new variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-issue-joining-while-creating-a-new-variable/m-p/78351#M288137</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No, this isn't a bad thing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SAS date and time processing can be a little confusing (as can be various DBMS products). The following link is to an overview in the SAS documentation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrcon/65287/HTML/default/viewer.htm#p1wj0wt2ebe2a0n1lv4lem9hdc0v.htm"&gt;http://support.sas.com/documentation/cdl/en/lrcon/65287/HTML/default/viewer.htm#p1wj0wt2ebe2a0n1lv4lem9hdc0v.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First of all, your DATE9. format simply tells SAS how to print the date, but doesn't influence the internal numeric value. That numeric value is either a number of days (a SAS DATE value), or a number of seconds (a DATETIME vale). Because of this, the underlying numbers are quite different.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try running this piece of code:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data datetest;&lt;BR /&gt;date1 = 18993;&lt;BR /&gt;format date1 date11.;&lt;BR /&gt;date2 = 1640995200;&lt;BR /&gt;format date2 datetime18.;&lt;BR /&gt;output;&lt;BR /&gt;run;&lt;BR /&gt;proc print;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You'll see that the printed date is 1 JAN 2012, even though the underlying numbers are quite different.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I suggest you print off a few of your date values from each table with no date formatting. The following code should print off a dozen from WORK.One:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc print data=work.one(obs=12);&lt;BR /&gt;var date;&lt;BR /&gt;format date best15.;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and do the same from WORK.Two.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If either is in a DATETIME format (the ten digit number), that's your problem. The data won't match properly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can convert any DATETIME values to DATE values with the DATEPART function, as demonstrated below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data datetest;&lt;BR /&gt;date1 = 18993;&lt;BR /&gt;format date1 date11.;&lt;BR /&gt;date2 = 1640995200;&lt;BR /&gt;format date2 datetime18.;&lt;BR /&gt;date3 = DATEPART(date2);&lt;BR /&gt;format date3 best16.;&lt;BR /&gt;date3f = date3;&lt;BR /&gt;format date3f date11.;&lt;BR /&gt;output;&lt;BR /&gt;run;&lt;BR /&gt;proc print;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Keep us posted!&lt;BR /&gt;&amp;nbsp; Tom&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Sep 2012 18:59:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-issue-joining-while-creating-a-new-variable/m-p/78351#M288137</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2012-09-28T18:59:26Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL issue - joining while creating a new variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-issue-joining-while-creating-a-new-variable/m-p/78352#M288138</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With your help I figured it out.&amp;nbsp; I didn't realize that the tables were organized by a different variable that also utilized the date variable so the join referenced both dates on the unseen variable.&amp;nbsp; &lt;/P&gt;&lt;P&gt;Thank you so much for your guidance.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;Regulator&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Sep 2012 19:18:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-issue-joining-while-creating-a-new-variable/m-p/78352#M288138</guid>
      <dc:creator>DasRegulator</dc:creator>
      <dc:date>2012-09-28T19:18:25Z</dc:date>
    </item>
  </channel>
</rss>

