<?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: joining tables: a version of many to one?? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/joining-tables-a-version-of-many-to-one/m-p/671842#M23392</link>
    <description>&lt;P&gt;With a variable name like qtr_a I might expect the value to be a date, especially since you are matching it on date_cpi, but it might be the qtr_a represents the first day of a quarter, such as 1 Jan 2010 and so there would be no matches for date_cpi if the values represent any day of the year.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A complete &lt;EM&gt;&lt;U&gt;&lt;STRONG&gt;guess&lt;/STRONG&gt;&lt;/U&gt;&lt;/EM&gt; of a possible solution might be something like&lt;/P&gt;
&lt;P&gt;ON A.qtr_a = intnx('quarter', B.date_cpi,0,'B') ;&lt;/P&gt;
&lt;P&gt;which would shift the b.date_cpi value to the first day of the calendar quarter for the comparison.&lt;/P&gt;
&lt;P&gt;You should verify what the values of A.qtr_a look like before attempting this though.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We know absolutely nothing about what/when/why any of your date_dispensed or date_cpi were collected. You would have to know if it makes sense to compare those.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One might also suspect there maybe should be some other identifier involved in the Join or Where criteria.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 23 Jul 2020 14:51:44 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2020-07-23T14:51:44Z</dc:date>
    <item>
      <title>joining tables: a version of many to one??</title>
      <link>https://communities.sas.com/t5/New-SAS-User/joining-tables-a-version-of-many-to-one/m-p/671658#M23383</link>
      <description>&lt;P&gt;Hi SAS users,&lt;/P&gt;&lt;P&gt;I need to join two tables, and no matter which way I go, I get many blank cells.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Table 1 has many rows with events and dates for each event.&lt;/P&gt;&lt;P&gt;Table 2 has 41 rows with inflation index by year and quarter for 10 years.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need a table that has inflation value matched to each date.&amp;nbsp; For example, all events occuring between January 1, 2010 and March 31, 2010 should have the inflation value for 2010Q1 in the new column.&lt;/P&gt;&lt;P&gt;My attempts at using proc sql (including left join) to join the tables are giving me thousands of blank cells in the inflation column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your help is, as always, appreciated!&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jul 2020 03:30:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/joining-tables-a-version-of-many-to-one/m-p/671658#M23383</guid>
      <dc:creator>drshashlik</dc:creator>
      <dc:date>2020-07-23T03:30:17Z</dc:date>
    </item>
    <item>
      <title>Re: joining tables: a version of many to one??</title>
      <link>https://communities.sas.com/t5/New-SAS-User/joining-tables-a-version-of-many-to-one/m-p/671663#M23384</link>
      <description>Here is my code:&lt;BR /&gt;This first set of code produces the correct number of rows, but the columns from table 'cpi' are blank after the first month of observations. Everything later than 2 january 2010 is blank.&lt;BR /&gt;PROC SQL;&lt;BR /&gt;CREATE TABLE rx_cpi AS&lt;BR /&gt;SELECT A.*, B.* FROM rx_q A full JOIN CPI B ON A.qtr_a = B.date_cpi ;QUIT;&lt;BR /&gt;/*n=48,289,242*/&lt;BR /&gt;&lt;BR /&gt;This version of the table removed thousands of rows.&lt;BR /&gt;proc sql; create table test as select a.*, b.* from r_rx as a, cpi as b where a.date_dispensed=b.date_cpi ; quit;&lt;BR /&gt;/*n=432,057*/</description>
      <pubDate>Thu, 23 Jul 2020 04:40:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/joining-tables-a-version-of-many-to-one/m-p/671663#M23384</guid>
      <dc:creator>drshashlik</dc:creator>
      <dc:date>2020-07-23T04:40:30Z</dc:date>
    </item>
    <item>
      <title>Re: joining tables: a version of many to one??</title>
      <link>https://communities.sas.com/t5/New-SAS-User/joining-tables-a-version-of-many-to-one/m-p/671734#M23386</link>
      <description>&lt;P&gt;Please supply example data in usable form (data steps with datalines), so we have something to test against, and know all attributes of your columns.&lt;/P&gt;
&lt;P&gt;Use the "little running man" button (right next to the one indicated, which is for logs) to post the codes:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Bildschirmfoto 2020-04-07 um 08.32.59.jpg"&gt;&lt;img src="https://communities.sas.com/skins/images/FD87FC08D4682D208909D8781B6AAB09/responsive_peak/images/image_not_found.png" alt="Bildschirmfoto 2020-04-07 um 08.32.59.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Mind that&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;SELECT A.*, B.*&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;is considered bad practice, as you have no control which variable is used if columns appear in both datasets (which will also cause a WARNING)&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jul 2020 09:47:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/joining-tables-a-version-of-many-to-one/m-p/671734#M23386</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-07-23T09:47:26Z</dc:date>
    </item>
    <item>
      <title>Re: joining tables: a version of many to one??</title>
      <link>https://communities.sas.com/t5/New-SAS-User/joining-tables-a-version-of-many-to-one/m-p/671842#M23392</link>
      <description>&lt;P&gt;With a variable name like qtr_a I might expect the value to be a date, especially since you are matching it on date_cpi, but it might be the qtr_a represents the first day of a quarter, such as 1 Jan 2010 and so there would be no matches for date_cpi if the values represent any day of the year.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A complete &lt;EM&gt;&lt;U&gt;&lt;STRONG&gt;guess&lt;/STRONG&gt;&lt;/U&gt;&lt;/EM&gt; of a possible solution might be something like&lt;/P&gt;
&lt;P&gt;ON A.qtr_a = intnx('quarter', B.date_cpi,0,'B') ;&lt;/P&gt;
&lt;P&gt;which would shift the b.date_cpi value to the first day of the calendar quarter for the comparison.&lt;/P&gt;
&lt;P&gt;You should verify what the values of A.qtr_a look like before attempting this though.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We know absolutely nothing about what/when/why any of your date_dispensed or date_cpi were collected. You would have to know if it makes sense to compare those.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One might also suspect there maybe should be some other identifier involved in the Join or Where criteria.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jul 2020 14:51:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/joining-tables-a-version-of-many-to-one/m-p/671842#M23392</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-07-23T14:51:44Z</dc:date>
    </item>
  </channel>
</rss>

