<?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 First and Last observations for Quarter and Account in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/First-and-Last-observations-for-Quarter-and-Account/m-p/637924#M21500</link>
    <description>&lt;P&gt;I have a data set that contains variables the following variables:&lt;/P&gt;&lt;P&gt;-account number (acctnum)&lt;/P&gt;&lt;P&gt;-date&lt;/P&gt;&lt;P&gt;-End of Quarter Date (i.e for 05/21/2018, EQD = 06/30/2018)&amp;nbsp;&lt;/P&gt;&lt;P&gt;-Balance&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to find the first and last value for balance for each end_of_quarter_date on an account by account basis.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried doing a data step with several combinations using of first.variable/last.variable, but can't seem to get the program to output what I need. Any help would be greatly appreciated!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 06 Apr 2020 19:02:22 GMT</pubDate>
    <dc:creator>orangekitty</dc:creator>
    <dc:date>2020-04-06T19:02:22Z</dc:date>
    <item>
      <title>First and Last observations for Quarter and Account</title>
      <link>https://communities.sas.com/t5/New-SAS-User/First-and-Last-observations-for-Quarter-and-Account/m-p/637924#M21500</link>
      <description>&lt;P&gt;I have a data set that contains variables the following variables:&lt;/P&gt;&lt;P&gt;-account number (acctnum)&lt;/P&gt;&lt;P&gt;-date&lt;/P&gt;&lt;P&gt;-End of Quarter Date (i.e for 05/21/2018, EQD = 06/30/2018)&amp;nbsp;&lt;/P&gt;&lt;P&gt;-Balance&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to find the first and last value for balance for each end_of_quarter_date on an account by account basis.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried doing a data step with several combinations using of first.variable/last.variable, but can't seem to get the program to output what I need. Any help would be greatly appreciated!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Apr 2020 19:02:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/First-and-Last-observations-for-Quarter-and-Account/m-p/637924#M21500</guid>
      <dc:creator>orangekitty</dc:creator>
      <dc:date>2020-04-06T19:02:22Z</dc:date>
    </item>
    <item>
      <title>Re: First and Last observations for Quarter and Account</title>
      <link>https://communities.sas.com/t5/New-SAS-User/First-and-Last-observations-for-Quarter-and-Account/m-p/637926#M21501</link>
      <description>&lt;P&gt;Are your date and end of quarter date variables actually SAS date values or something else?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What do you want the output to look like?&lt;/P&gt;
&lt;P&gt;It helps to provide example data in the form of a data step so we don't have to ask a lot of questions about your current data. Instructions here: &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; will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the &amp;lt;&amp;gt; icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the values are actual SAS dates and hence would sort appropriately:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Proc sort data =have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; by account date;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; by account date endofquarter;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; if first.endofquarter or last.endofquarter;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;would have a data set with two records per quarter (assuming there are two or more).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If that doesn't work you &lt;STRONG&gt;need&lt;/STRONG&gt; to provide some example data and the desired output for the given data.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Apr 2020 19:12:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/First-and-Last-observations-for-Quarter-and-Account/m-p/637926#M21501</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-04-06T19:12:47Z</dc:date>
    </item>
    <item>
      <title>Re: First and Last observations for Quarter and Account</title>
      <link>https://communities.sas.com/t5/New-SAS-User/First-and-Last-observations-for-Quarter-and-Account/m-p/637930#M21502</link>
      <description>The output needs to be in the format of endofquarter_balance and beginningofquarter_balance for each account at a given quarterly level.</description>
      <pubDate>Mon, 06 Apr 2020 19:30:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/First-and-Last-observations-for-Quarter-and-Account/m-p/637930#M21502</guid>
      <dc:creator>orangekitty</dc:creator>
      <dc:date>2020-04-06T19:30:15Z</dc:date>
    </item>
    <item>
      <title>Re: First and Last observations for Quarter and Account</title>
      <link>https://communities.sas.com/t5/New-SAS-User/First-and-Last-observations-for-Quarter-and-Account/m-p/637934#M21503</link>
      <description>&lt;P&gt;So each observations for a quarter has the same EDQ value?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have ;
  by accnum edq date ;
  if first.edq then opening_balance=balance ;
  retain opening_balance;
  if last.edq ;
  keep accnum edq opening_balance balance ;
  rename balance=closing_balance;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 06 Apr 2020 20:06:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/First-and-Last-observations-for-Quarter-and-Account/m-p/637934#M21503</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-04-06T20:06:46Z</dc:date>
    </item>
  </channel>
</rss>

