<?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: Merge monthly data - PROC APPEND in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Merge-monthly-data-PROC-APPEND/m-p/173521#M33300</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;They're saying the store the data in a long format, as mentioned here:&lt;/P&gt;&lt;P&gt;&lt;A __default_attr="64245" __jive_macro_name="thread" class="jive_macro jive_macro_thread" href="https://communities.sas.com/" modifiedtitle="true" title="Program to rename, change and merge table month over month."&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And only use your wide format to create your reports. It's easier than adding columns every time your table rather than just appending rows each time. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 08 Jan 2015 13:51:19 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2015-01-08T13:51:19Z</dc:date>
    <item>
      <title>Merge monthly data - PROC APPEND</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-monthly-data-PROC-APPEND/m-p/173517#M33296</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have created a table which I will need to run on a montly basis to compare pricing changes month over month on products and services, and to detemine when a new product or service is introduced.&amp;nbsp; I will be running my report at the beginning of each month and then performing a PROC APPEND to merge the products and services.&amp;nbsp; The first month I will need all information brought in.&amp;nbsp; After that I just need the updated pricing for that current month and also any new products or services that were introduced.&amp;nbsp; I need to have my read vertically in columns similar to the ones I pasted below.&amp;nbsp; I understand that I will need to Transpose my data afterwards to change the view from horizontal to vertical.&amp;nbsp; The SOC, Feature and Description columns will remain constanst however I will need to add a new column ever month, for ex. Rate_201501, Rate_201502, Rate_201503.&amp;nbsp; every&amp;nbsp; I will have approx 50k record in my table.&amp;nbsp; Most months, the Products and Services will not change, just the rate might change.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am assuming that I will probably need to insert another column to my current table so that I can insert the Month/Year that I am running the table for. I have no run date field in my current table.&amp;nbsp; When I run multiple tables now, it will list all my results horizontally.&amp;nbsp; I have no way of distinguishing which variables are from which month.&amp;nbsp; My question is, how do I add the date month over month to my current table and have it display as it does in the second table?&amp;nbsp; Maybe I'm going about this wrong but any input would be appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;These are the fields on my current table.&amp;nbsp; Right now my data is displayed horizontally.&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" width="612"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD height="20" width="106"&gt;SOC&lt;/TD&gt;&lt;TD width="106"&gt;FEATURE_CODE&lt;/TD&gt;&lt;TD width="75"&gt;RATE&lt;/TD&gt;&lt;TD width="219"&gt;SOC_DESCRIPTION&lt;/TD&gt;&lt;TD width="106"&gt;PRODUCT_TYPE&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is how I want my table to look as I am adding the months in.&amp;nbsp; I need to Transpose my data so that it displays vertically in this format.&amp;nbsp; And I need to add a new header each month.&amp;nbsp; Not sure how I can achive this.&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" width="718"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl63" height="20" width="64"&gt;SOC &lt;/TD&gt;&lt;TD class="xl63" width="64"&gt;Feature&lt;/TD&gt;&lt;TD class="xl63" width="146"&gt;Feature Description&lt;/TD&gt;&lt;TD class="xl64" width="106"&gt;Rate_201412&lt;/TD&gt;&lt;TD class="xl63" width="137"&gt;Rate_201501&lt;/TD&gt;&lt;TD class="xl63" width="109"&gt;Rate_201502&lt;/TD&gt;&lt;TD class="xl63" width="92"&gt;Rate_201503&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Jan 2015 21:55:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-monthly-data-PROC-APPEND/m-p/173517#M33296</guid>
      <dc:creator>Giuliano</dc:creator>
      <dc:date>2015-01-07T21:55:31Z</dc:date>
    </item>
    <item>
      <title>Re: Merge monthly data - PROC APPEND</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-monthly-data-PROC-APPEND/m-p/173518#M33297</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use PROC TRANSPOSE or a data step to transpose your data. There are tons of examples available.&lt;/P&gt;&lt;P&gt;But, why? Your target table will be more difficult and less flexible to build reports on. Let the reporting tolls do the layout for you. Keep the period and the rate in separate columns, much easier to maintain.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Jan 2015 09:16:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-monthly-data-PROC-APPEND/m-p/173518#M33297</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2015-01-08T09:16:56Z</dc:date>
    </item>
    <item>
      <title>Re: Merge monthly data - PROC APPEND</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-monthly-data-PROC-APPEND/m-p/173519#M33298</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I concur with LinusH, if you have that many records then you are going to end up with vast amounts of columns.&amp;nbsp; I would recommend keeping it normalized unless there is actually a requirement.&amp;nbsp; AS for the date, I couldn't see anything in the horizontal structure you showed to have date, so how is that arrived at.&amp;nbsp; Paste some actual data and what you are trying to achieve.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Jan 2015 09:34:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-monthly-data-PROC-APPEND/m-p/173519#M33298</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-01-08T09:34:34Z</dc:date>
    </item>
    <item>
      <title>Re: Merge monthly data - PROC APPEND</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-monthly-data-PROC-APPEND/m-p/173520#M33299</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Ok, so you are saying that I should use PROC REPORT after I do my PROC APPEND to display the results needed?&amp;nbsp; And forget about about using PROC TRANPOSE?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Jan 2015 13:43:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-monthly-data-PROC-APPEND/m-p/173520#M33299</guid>
      <dc:creator>Giuliano</dc:creator>
      <dc:date>2015-01-08T13:43:12Z</dc:date>
    </item>
    <item>
      <title>Re: Merge monthly data - PROC APPEND</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-monthly-data-PROC-APPEND/m-p/173521#M33300</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;They're saying the store the data in a long format, as mentioned here:&lt;/P&gt;&lt;P&gt;&lt;A __default_attr="64245" __jive_macro_name="thread" class="jive_macro jive_macro_thread" href="https://communities.sas.com/" modifiedtitle="true" title="Program to rename, change and merge table month over month."&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And only use your wide format to create your reports. It's easier than adding columns every time your table rather than just appending rows each time. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Jan 2015 13:51:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-monthly-data-PROC-APPEND/m-p/173521#M33300</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-01-08T13:51:19Z</dc:date>
    </item>
    <item>
      <title>Re: Merge monthly data - PROC APPEND</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-monthly-data-PROC-APPEND/m-p/173522#M33301</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok perfect, thank you Reeza.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Jan 2015 14:01:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-monthly-data-PROC-APPEND/m-p/173522#M33301</guid>
      <dc:creator>Giuliano</dc:creator>
      <dc:date>2015-01-08T14:01:24Z</dc:date>
    </item>
    <item>
      <title>Re: Merge monthly data - PROC APPEND</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-monthly-data-PROC-APPEND/m-p/173523#M33302</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;A more normal data structure might look something like this (presuming SOC is the unique key):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;SOC_Dim&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;SOC&lt;/P&gt;&lt;P&gt;SOC_Description&lt;/P&gt;&lt;P&gt;Feature_Code&lt;/P&gt;&lt;P&gt;Product_Type&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;SOC_Fact&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;SOC&lt;/P&gt;&lt;P&gt;Business_Date&lt;/P&gt;&lt;P&gt;Rate&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You would need to insert new products records into SOC_DIM each month and all records into the fact table:&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table work.soc_new as &lt;/P&gt;&lt;P&gt;select&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t1.SOC&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t1.SOC_Description&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t1.Feature_Code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t1.Product_Type&lt;/P&gt;&lt;P&gt;from&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NewData t1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; left outer join work.soc_dim t2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; on t1.soc=t2.soc&lt;/P&gt;&lt;P&gt;where&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t2.soc is null;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;insert into soc_dim (&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SOC&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SOC_Description&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Feature_Code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Product_Type)&lt;/P&gt;&lt;P&gt;select&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SOC&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SOC_Description&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Feature_Code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Product_Type&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;from work.soc_new;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;insert into SOC_FACT (&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; soc,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; business_Date,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rate)&lt;/P&gt;&lt;P&gt;select&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; soc,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; business_date, /*not sure where the date actually comes from*/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rate&lt;/P&gt;&lt;P&gt;from&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; work.new_data;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then, it's a fairly straightforward question to use in queries/views:&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;select&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t1.*,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t2.rate as Rate_20141231&lt;/P&gt;&lt;P&gt;from&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; soc_dim t1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; left outer join (select * from soc_dim where business_Date='31dec2014'd) t2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; on t1.soc=t2.soc&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Jan 2015 14:03:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-monthly-data-PROC-APPEND/m-p/173523#M33302</guid>
      <dc:creator>DBailey</dc:creator>
      <dc:date>2015-01-08T14:03:29Z</dc:date>
    </item>
  </channel>
</rss>

