<?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: Find last date value in a field and return value to a new field in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Find-last-date-value-in-a-field-and-return-value-to-a-new-field/m-p/247655#M17555</link>
    <description>&lt;P&gt;Thanks Tom and Jag for you assistance, very much appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Tom your solution was exactly what I was after.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;Haydn&lt;/P&gt;</description>
    <pubDate>Wed, 03 Feb 2016 03:06:31 GMT</pubDate>
    <dc:creator>Haydn</dc:creator>
    <dc:date>2016-02-03T03:06:31Z</dc:date>
    <item>
      <title>Find last date value in a field and return value to a new field</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Find-last-date-value-in-a-field-and-return-value-to-a-new-field/m-p/247631#M17549</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following code, which merges monthly data sets. Each dataset will have a field called 'report_date' and this will have the month and year. Example the monthlytblejul2015 dataset will have JUL2015, the monthlytbledec2015 will have DEC2015 in the 'report_date' field. What I am trying to achieve is create a new field, called "Report_Month"&amp;nbsp;in the merged dataset&amp;nbsp;and &amp;nbsp;every row return the last value in the "report_date' field, in the case that would be DEC2015. Next month when I merge January 2016 data to the dataset, this value would then be JAN2016. I have tried Max, but this duplicates the 'report_date' column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is appreciated&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data vaload.ind_monthly_report;
merge 
reports.monthlytblejul2015          
reports.monthlytbleaug2015 
reports.monthlytblesep2015
reports.monthlytbleoct2015  
reports.monthlytblenov2015
reports.monthlytbledec2015
;
 
by  report_date;     
 Report_Month= max(report_date) ; 
format Report_Month monyy7.;

run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 02 Feb 2016 22:55:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Find-last-date-value-in-a-field-and-return-value-to-a-new-field/m-p/247631#M17549</guid>
      <dc:creator>Haydn</dc:creator>
      <dc:date>2016-02-02T22:55:25Z</dc:date>
    </item>
    <item>
      <title>Re: Find last date value in a field and return value to a new field</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Find-last-date-value-in-a-field-and-return-value-to-a-new-field/m-p/247639#M17550</link>
      <description>&lt;P&gt;we could merge the datasets without the by statement like below and rename the dates in every dataset, by this way all the datasets will align side by side with different dates and then you could create a new variable with the max date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By using the by statement you are trying to merge the datasets on dates, since they do not have the common dates in all datasets, merge will not occur.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is an untested code, please try and let me know if it helps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data vaload.ind_monthly_report;
merge 
reports.monthlytblejul2015(rename=(report_date=report_date1))          
reports.monthlytbleaug2015 (rename=(report_date=report_date2))
reports.monthlytblesep2015(rename=(report_date=report_date3))
reports.monthlytbleoct2015  (rename=(report_date=report_date4))
reports.monthlytblenov2015(rename=(report_date=report_date5))
reports.monthlytbledec2015(rename=(report_date=report_date6))
;
     
Report_Month= max(of report_date1-report_date6) ; 
format Report_Month monyy7.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 03 Feb 2016 00:46:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Find-last-date-value-in-a-field-and-return-value-to-a-new-field/m-p/247639#M17550</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2016-02-03T00:46:28Z</dc:date>
    </item>
    <item>
      <title>Re: Find last date value in a field and return value to a new field</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Find-last-date-value-in-a-field-and-return-value-to-a-new-field/m-p/247642#M17551</link>
      <description>&lt;P&gt;Thanks Jag,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That does give me a me field with the latest date. Is there any way I can keep the original 'report_date' field with it's values, as I use this in SAS VA to trend this report over time?&lt;/P&gt;</description>
      <pubDate>Wed, 03 Feb 2016 01:20:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Find-last-date-value-in-a-field-and-return-value-to-a-new-field/m-p/247642#M17551</guid>
      <dc:creator>Haydn</dc:creator>
      <dc:date>2016-02-03T01:20:10Z</dc:date>
    </item>
    <item>
      <title>Re: Find last date value in a field and return value to a new field</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Find-last-date-value-in-a-field-and-return-value-to-a-new-field/m-p/247645#M17552</link>
      <description>&lt;P&gt;if i understand you correctly, you want to have the report_date variable merged from different datasets same in the final output. if this is the case, then I am not sure if there is a way to have the same variable name for different columns in same dataset, if you want to disaply all of the columns. However if you want to display the most recent dataset with same column name then it is possible.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please try&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data vaload.ind_monthly_report;
merge 
reports.monthlytblejul2015(rename=(report_date=report_date1))          
reports.monthlytbleaug2015 (rename=(report_date=report_date2))
reports.monthlytblesep2015(rename=(report_date=report_date3))
reports.monthlytbleoct2015  (rename=(report_date=report_date4))
reports.monthlytblenov2015(rename=(report_date=report_date5))
reports.monthlytbledec2015
;
Report_Month= max(report_date1, report_date2, report_date3, report_date4, report_date5, report_date6, report_date) ; 
format Report_Month monyy7.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 03 Feb 2016 01:53:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Find-last-date-value-in-a-field-and-return-value-to-a-new-field/m-p/247645#M17552</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2016-02-03T01:53:29Z</dc:date>
    </item>
    <item>
      <title>Re: Find last date value in a field and return value to a new field</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Find-last-date-value-in-a-field-and-return-value-to-a-new-field/m-p/247647#M17554</link>
      <description>&lt;P&gt;Examples of actual numbers would help. &amp;nbsp;I suspect that you want to use a SET statement to combine the tables vertically instead of a MERGE statement which would try to merge the data horizontally.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data vaload.ind_monthly_report;
  set 
    reports.monthlytblejul2015          
    reports.monthlytbleaug2015 
    reports.monthlytblesep2015
    reports.monthlytbleoct2015  
    reports.monthlytblenov2015
    reports.monthlytbledec2015
  ;
  by  descending report_date ;
  if _n_=1 then Report_Month= report_date ;
  retain Report_Month;
  format Report_Month monyy7.;
run;&lt;/CODE&gt;&amp;nbsp;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Feb 2016 02:33:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Find-last-date-value-in-a-field-and-return-value-to-a-new-field/m-p/247647#M17554</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2016-02-03T02:33:33Z</dc:date>
    </item>
    <item>
      <title>Re: Find last date value in a field and return value to a new field</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Find-last-date-value-in-a-field-and-return-value-to-a-new-field/m-p/247655#M17555</link>
      <description>&lt;P&gt;Thanks Tom and Jag for you assistance, very much appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Tom your solution was exactly what I was after.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;Haydn&lt;/P&gt;</description>
      <pubDate>Wed, 03 Feb 2016 03:06:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Find-last-date-value-in-a-field-and-return-value-to-a-new-field/m-p/247655#M17555</guid>
      <dc:creator>Haydn</dc:creator>
      <dc:date>2016-02-03T03:06:31Z</dc:date>
    </item>
  </channel>
</rss>

