<?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: Finding Changes in Data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Finding-Changes-in-Data/m-p/405584#M279180</link>
    <description>&lt;P&gt;You may be able to get away with:&lt;/P&gt;
&lt;PRE&gt;proc sql;
  create table WANT as
  select  *
  from    (select distinct YEAR,MONTH,DEPART,DEST from HAVE)
  where   count(*) &amp;gt; 1;
quit;&lt;/PRE&gt;
&lt;P&gt;Not not tested, post test data in the form of a datastep.&lt;/P&gt;</description>
    <pubDate>Thu, 19 Oct 2017 15:00:24 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2017-10-19T15:00:24Z</dc:date>
    <item>
      <title>Finding Changes in Data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-Changes-in-Data/m-p/405578#M279179</link>
      <description>&lt;P&gt;I have a program that provides output as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Year&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Month&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; depart&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dest&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Count&lt;/P&gt;&lt;P&gt;2017&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CYVR&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CYYZ&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 578&lt;/P&gt;&lt;P&gt;2017&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CYOW&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CYYZ&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;578&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;These are airport departure and destination codes. I can select which month/year combo I want and all is good.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the question, how can I compare two months (say August 2016 and August 2016) and have ONLY&amp;nbsp;CHANGED CITY PAIRS come out.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm thinking I will need to concatenate depart and dest to, say, departdest (e.g., CYVRCYYZ from above) and use that variable to compare. Essentially I am only interesting in saying:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"When comparing August 2017 to August 2016 the following city pairs were added. When comparing August 2017 to August 2016 the following city pairs were removed."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any initial ideas would be great&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thx&lt;/P&gt;</description>
      <pubDate>Thu, 19 Oct 2017 14:53:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-Changes-in-Data/m-p/405578#M279179</guid>
      <dc:creator>BCNAV</dc:creator>
      <dc:date>2017-10-19T14:53:45Z</dc:date>
    </item>
    <item>
      <title>Re: Finding Changes in Data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-Changes-in-Data/m-p/405584#M279180</link>
      <description>&lt;P&gt;You may be able to get away with:&lt;/P&gt;
&lt;PRE&gt;proc sql;
  create table WANT as
  select  *
  from    (select distinct YEAR,MONTH,DEPART,DEST from HAVE)
  where   count(*) &amp;gt; 1;
quit;&lt;/PRE&gt;
&lt;P&gt;Not not tested, post test data in the form of a datastep.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Oct 2017 15:00:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-Changes-in-Data/m-p/405584#M279180</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-10-19T15:00:24Z</dc:date>
    </item>
    <item>
      <title>Re: Finding Changes in Data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-Changes-in-Data/m-p/405586#M279181</link>
      <description>PROC SQL with INTERSECT for the same and EXCEPT for the differences. Or PROC COMPARE but I don't find that as easy to use. If you want more help, please post sample data and expected output. &lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt;</description>
      <pubDate>Thu, 19 Oct 2017 15:02:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-Changes-in-Data/m-p/405586#M279181</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-19T15:02:45Z</dc:date>
    </item>
    <item>
      <title>Re: Finding Changes in Data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-Changes-in-Data/m-p/405604#M279182</link>
      <description>&lt;P&gt;Here is more info&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have two tables:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;AUGUST_2017&lt;/P&gt;&lt;P&gt;AUGUST_2016&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Each table contains airport city pair data (I can post data if needed). Data looks like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;AUGUST_2017:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Year&amp;nbsp;&amp;nbsp; Month&amp;nbsp;&amp;nbsp; depart&amp;nbsp;&amp;nbsp; dest&amp;nbsp;&amp;nbsp; Count&lt;BR /&gt;2017&amp;nbsp;&amp;nbsp; 8&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CYVR&amp;nbsp;&amp;nbsp; CYYZ&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 578&lt;BR /&gt;2017&amp;nbsp;&amp;nbsp; 8&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CYYZ&amp;nbsp;&amp;nbsp;&amp;nbsp; CYVR&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 577&lt;BR /&gt;2017&amp;nbsp;&amp;nbsp; 8&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CYOW&amp;nbsp; CYYZ&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 530&lt;BR /&gt;2017&amp;nbsp;&amp;nbsp; 8&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CYYZ&amp;nbsp;&amp;nbsp;&amp;nbsp; CYOW&amp;nbsp;&amp;nbsp;&amp;nbsp; 529&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;AUGUST_2016:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Year&amp;nbsp;&amp;nbsp; Month&amp;nbsp;&amp;nbsp; depart&amp;nbsp;&amp;nbsp; dest&amp;nbsp;&amp;nbsp; Count&lt;BR /&gt;2016&amp;nbsp;&amp;nbsp; 8&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CYVR&amp;nbsp;&amp;nbsp; CYYZ&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 578&lt;BR /&gt;2016&amp;nbsp;&amp;nbsp; 8&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CYYZ&amp;nbsp;&amp;nbsp;&amp;nbsp; CYVR&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 577&lt;BR /&gt;2016&amp;nbsp;&amp;nbsp; 8&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CYOW&amp;nbsp; CYYZ&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 530&lt;BR /&gt;2016&amp;nbsp;&amp;nbsp; 8&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CYYZ&amp;nbsp;&amp;nbsp;&amp;nbsp; CYOW&amp;nbsp;&amp;nbsp;&amp;nbsp; 529&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and so on for thousands of flights.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to be able to query both existing tables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The first query would be to check what is in AUGUST_2017 that is not in AUGUST_2016. These would be added flights.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The second query would be to check what is in AUGUST_2016 that is not in AUGUST_2017. These would be&amp;nbsp;flights removed by the airline.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't think my original post was clear enough. Sorry.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Oct 2017 15:24:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-Changes-in-Data/m-p/405604#M279182</guid>
      <dc:creator>BCNAV</dc:creator>
      <dc:date>2017-10-19T15:24:17Z</dc:date>
    </item>
    <item>
      <title>Re: Finding Changes in Data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-Changes-in-Data/m-p/405609#M279183</link>
      <description>Did EXCEPT not work? If not, post your code and log.</description>
      <pubDate>Thu, 19 Oct 2017 15:35:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-Changes-in-Data/m-p/405609#M279183</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-19T15:35:03Z</dc:date>
    </item>
    <item>
      <title>Re: Finding Changes in Data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-Changes-in-Data/m-p/405617#M279184</link>
      <description>&lt;P&gt;I am not sure of the code..can you post the sql&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;PROC&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;SQL&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;CREATE&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;TABLE&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; EGTASK.TEST2 &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;AS&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;SELECT&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; t1.depart, &lt;/FONT&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;&amp;nbsp; t1.dest&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;intersect&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; EGTASK.AUGUST_2017 t1, EGTASK.AUGUST_2016 t2;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;QUIT&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Oct 2017 15:51:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-Changes-in-Data/m-p/405617#M279184</guid>
      <dc:creator>BCNAV</dc:creator>
      <dc:date>2017-10-19T15:51:00Z</dc:date>
    </item>
    <item>
      <title>Re: Finding Changes in Data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-Changes-in-Data/m-p/405620#M279185</link>
      <description>&lt;P&gt;1. Your sample data all are the same so there are no differences to be found&lt;/P&gt;
&lt;P&gt;2. You didn't put them as a data step so I'd have to write code to import your data first&lt;/P&gt;
&lt;P&gt;3. To demonstrate&amp;nbsp;an actual&amp;nbsp;example I'd have to add new data that would show the differences&lt;/P&gt;
&lt;P&gt;4. The code below is INTERSECT which would show the same in both data sets. EXCEPT will show the exceptions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So even if the code worked, there's no way to test it at present with your sample data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a reference for the SQL operators with examples&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www2.sas.com/proceedings/sugi31/242-31.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi31/242-31.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Oct 2017 15:55:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-Changes-in-Data/m-p/405620#M279185</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-19T15:55:29Z</dc:date>
    </item>
    <item>
      <title>Re: Finding Changes in Data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-Changes-in-Data/m-p/405662#M279186</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="delete_sample_data.JPG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/16018iF1FE4B0F13BF6FB2/image-size/large?v=v2&amp;amp;px=999" role="button" title="delete_sample_data.JPG" alt="delete_sample_data.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a solution that doesn't scale well to multiple data sets IMO. You need to manually code it and customize for each month.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="delete_scale1.JPG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/16019i645141BAB5DBF0A4/image-size/large?v=v2&amp;amp;px=999" role="button" title="delete_scale1.JPG" alt="delete_scale1.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And an SQL option that does scale, using EXCEPT&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="delete_scale2.JPG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/16020iF1317DD2C691B763/image-size/large?v=v2&amp;amp;px=999" role="button" title="delete_scale2.JPG" alt="delete_scale2.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Oct 2017 17:07:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-Changes-in-Data/m-p/405662#M279186</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-19T17:07:11Z</dc:date>
    </item>
    <item>
      <title>Re: Finding Changes in Data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-Changes-in-Data/m-p/405930#M279187</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tested and your solution is perfect. I ended up with:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* The code below will get all flights that were removed from the previous year */
PROC SQL;
	CREATE TABLE EGTASK.ACM_FLT_REMOVED AS
		SELECT depart, dest
			FROM EGTASK.CITY_PR_TOTAL_PYEAR
				EXCEPT
			SELECT depart, dest from EGTASK.CITY_PR_TOTAL_CYEAR;
QUIT;

/* The code below will get all flights that were added in the current year */
PROC SQL;
	CREATE TABLE EGTASK.ACM_FLT_ADDED AS
		SELECT depart, dest
			FROM EGTASK.CITY_PR_TOTAL_CYEAR
				EXCEPT
			SELECT depart, dest from EGTASK.CITY_PR_TOTAL_PYEAR;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;As you can see I have generalized it to current year (CYEAR) and previous year (PYEAR).&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Thanks!&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2017 12:23:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-Changes-in-Data/m-p/405930#M279187</guid>
      <dc:creator>BCNAV</dc:creator>
      <dc:date>2017-10-20T12:23:50Z</dc:date>
    </item>
  </channel>
</rss>

