<?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: Code help in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Code-help/m-p/294189#M61350</link>
    <description>&lt;P&gt;Try to build something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table QHPNOTEPtable_1 as
select 
	Q.*,
	coalesce(M0.market_name, M1.market_name, M2.market_name) as market_name 
from 
	QHPNOTEPtable as Q left join 
	table1 as M0 on Q.grPnum= M0.group_ID left join
	table1 as M1 on Q.grPnum= M1.group_ID left join
	table1 as M2 on Q.grPnum= M2.group_ID
where 
	M0.year=2016 and 
	M1.year=2015 and 
	M2.year=2014;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 25 Aug 2016 20:38:30 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2016-08-25T20:38:30Z</dc:date>
    <item>
      <title>Code help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Code-help/m-p/294181#M61349</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We have a table1 which contains marketname ,year &amp;nbsp;fields that has the data from the year 2014 to 2016.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Currently we are pulling data from table1 for the year 2016. While we join with this table 1 to get marketname for 2016 and its not matching. But if there is no matching, please match by previous year names table, if still not, use previous previous year&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, if 2016 name not match, then use 2015, if still not, use 2014.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please let me know how to go back for previous years and get the names.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt; &lt;STRONG&gt;sql&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;create table QHPNOTEPtable_1 as&lt;/P&gt;&lt;P&gt;select Q.*,M.market_name from QHPNOTEPtable Q&lt;/P&gt;&lt;P&gt;left join table1 M ON Q.grPnum= M.group_ID;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Aug 2016 20:13:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Code-help/m-p/294181#M61349</guid>
      <dc:creator>cho16</dc:creator>
      <dc:date>2016-08-25T20:13:09Z</dc:date>
    </item>
    <item>
      <title>Re: Code help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Code-help/m-p/294189#M61350</link>
      <description>&lt;P&gt;Try to build something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table QHPNOTEPtable_1 as
select 
	Q.*,
	coalesce(M0.market_name, M1.market_name, M2.market_name) as market_name 
from 
	QHPNOTEPtable as Q left join 
	table1 as M0 on Q.grPnum= M0.group_ID left join
	table1 as M1 on Q.grPnum= M1.group_ID left join
	table1 as M2 on Q.grPnum= M2.group_ID
where 
	M0.year=2016 and 
	M1.year=2015 and 
	M2.year=2014;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Aug 2016 20:38:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Code-help/m-p/294189#M61350</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-08-25T20:38:30Z</dc:date>
    </item>
    <item>
      <title>Re: Code help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Code-help/m-p/294248#M61365</link>
      <description>&lt;PRE&gt;
Post some data to let us test it . and post the output you want to see.


&lt;/PRE&gt;</description>
      <pubDate>Fri, 26 Aug 2016 01:55:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Code-help/m-p/294248#M61365</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-08-26T01:55:51Z</dc:date>
    </item>
  </channel>
</rss>

