<?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: Dif() function and first observation in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Dif-function-and-first-observation/m-p/409052#M67145</link>
    <description>&lt;P&gt;Thank God for this forum! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 31 Oct 2017 10:42:46 GMT</pubDate>
    <dc:creator>GKati</dc:creator>
    <dc:date>2017-10-31T10:42:46Z</dc:date>
    <item>
      <title>Dif() function and first observation</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Dif-function-and-first-observation/m-p/409049#M67143</link>
      <description>&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p2"&gt;&lt;SPAN class="s1"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt; clients;&lt;/P&gt;&lt;P class="p2"&gt;&lt;SPAN class="s2"&gt;input&lt;/SPAN&gt; client year cost;&lt;/P&gt;&lt;P class="p3"&gt;datalines&lt;SPAN class="s3"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p2"&gt;18 2011 589.92&lt;/P&gt;&lt;P class="p2"&gt;18 2010 1629.8&lt;/P&gt;&lt;P class="p2"&gt;18 2011 1813.29&lt;/P&gt;&lt;P class="p2"&gt;18 2012 412.06&lt;/P&gt;&lt;P class="p2"&gt;19 2012 219.82&lt;/P&gt;&lt;P class="p2"&gt;20 2010 3669.98&lt;/P&gt;&lt;P class="p2"&gt;20 2012 4879.63&lt;/P&gt;&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p2"&gt;;&lt;/P&gt;&lt;P class="p4"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;SPAN class="s3"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p4"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt; work.client2;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s2"&gt;set&lt;/SPAN&gt; work.client;&lt;/P&gt;&lt;P class="p1"&gt;dif_cost=dif(cost);&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s2"&gt;if&lt;/SPAN&gt; first.client&amp;nbsp;&lt;SPAN class="s2"&gt;then&lt;/SPAN&gt; dif_cost = &lt;SPAN class="s3"&gt;&lt;STRONG&gt;.&lt;/STRONG&gt;&lt;/SPAN&gt; ;&lt;/P&gt;&lt;P class="p2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;SPAN class="s4"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p2"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p2"&gt;&lt;SPAN class="s4"&gt;I get an error message that f&lt;SPAN&gt;irst.client is uninitialized. Why? My data is sorted by client and year.&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p2"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p2"&gt;&lt;SPAN class="s4"&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Oct 2017 10:38:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Dif-function-and-first-observation/m-p/409049#M67143</guid>
      <dc:creator>GKati</dc:creator>
      <dc:date>2017-10-31T10:38:24Z</dc:date>
    </item>
    <item>
      <title>Re: Dif() function and first observation</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Dif-function-and-first-observation/m-p/409050#M67144</link>
      <description>&lt;P&gt;Yes, your data is in order.&amp;nbsp; But that does not create FIRST. and LAST. variables.&amp;nbsp; To do that, you have to add the BY statement in the DATA step:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data work.client2;&lt;/P&gt;
&lt;P&gt;set work.client;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;by client;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The BY statement is what creates FIRST.CLIENT.&amp;nbsp; It doesn't put your data in order ... the data must be in order before the DATA step begins to make the BY statement legal.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Oct 2017 10:39:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Dif-function-and-first-observation/m-p/409050#M67144</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-10-31T10:39:13Z</dc:date>
    </item>
    <item>
      <title>Re: Dif() function and first observation</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Dif-function-and-first-observation/m-p/409052#M67145</link>
      <description>&lt;P&gt;Thank God for this forum! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Oct 2017 10:42:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Dif-function-and-first-observation/m-p/409052#M67145</guid>
      <dc:creator>GKati</dc:creator>
      <dc:date>2017-10-31T10:42:46Z</dc:date>
    </item>
  </channel>
</rss>

