<?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: New at SAS, Is it possible to recalculate values based on 2 conditions? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/New-at-SAS-Is-it-possible-to-recalculate-values-based-on-2/m-p/23112#M5079</link>
    <description>Hi:&lt;BR /&gt;
  For a better understanding of the LAG function for future use and to understand why Doc's suggestion will work, these are good resources:&lt;BR /&gt;
    &lt;BR /&gt;
&lt;A href="http://support.sas.com/kb/24/665.html" target="_blank"&gt;http://support.sas.com/kb/24/665.html&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://support.sas.com/resources/papers/proceedings09/055-2009.pdf" target="_blank"&gt;http://support.sas.com/resources/papers/proceedings09/055-2009.pdf&lt;/A&gt; (look at the explanation for table 2a, page 3 in this paper)&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/etsug/63348/HTML/default/viewer.htm#/documentation/cdl/en/etsug/63348/HTML/default/etsug_tsdata_sect048.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/etsug/63348/HTML/default/viewer.htm#/documentation/cdl/en/etsug/63348/HTML/default/etsug_tsdata_sect048.htm&lt;/A&gt; (discussion of the pitfalls of the LAG and DIF functions)&lt;BR /&gt;
      &lt;BR /&gt;
cynthia</description>
    <pubDate>Mon, 17 May 2010 17:15:54 GMT</pubDate>
    <dc:creator>Cynthia_sas</dc:creator>
    <dc:date>2010-05-17T17:15:54Z</dc:date>
    <item>
      <title>New at SAS, Is it possible to recalculate values based on 2 conditions?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/New-at-SAS-Is-it-possible-to-recalculate-values-based-on-2/m-p/23110#M5077</link>
      <description>Hey everyone,&lt;BR /&gt;
&lt;BR /&gt;
Im new at SAS so i apologize for asking what i assume is a pretty basic function. I have a few million observations and i cant just edit my csv file so i need to manipulate the data in SAS. Im looking to use a function to make a calculation based on any changes in the data in the first two columns.&lt;BR /&gt;
&lt;BR /&gt;
I would be grateful if someone can tell me if this is possible or do i have to use the proc sql command. Perhaps a screenshot and my coding will help explain better.&lt;BR /&gt;
&lt;BR /&gt;
&lt;A href="http://img148.imageshack.us/img148/6771/49349620.jpg" target="_blank"&gt;http://img148.imageshack.us/img148/6771/49349620.jpg&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
Based on the example in the screenshot above, i'm calculating R=log(P/lag(P)). &lt;BR /&gt;
If you look at the screenshot, R is what i want to achieve, while "Wrong R" is what i get from using the code below.&lt;BR /&gt;
&lt;BR /&gt;
data example1;&lt;BR /&gt;
	set example2;&lt;BR /&gt;
	by variable date;&lt;BR /&gt;
	r=log(P/lag(P));&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
The conditions to get R is that every time theres changes in the column Variable and Date, I want the data in R for that field to reset to NA as i cant utilize the pre-existing data point in column P.&lt;BR /&gt;
&lt;BR /&gt;
I hope that explains it well enough, appreciate any help i can get, thanks in advance!</description>
      <pubDate>Mon, 17 May 2010 14:55:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/New-at-SAS-Is-it-possible-to-recalculate-values-based-on-2/m-p/23110#M5077</guid>
      <dc:creator>adrian_waw</dc:creator>
      <dc:date>2010-05-17T14:55:39Z</dc:date>
    </item>
    <item>
      <title>Re: New at SAS, Is it possible to recalculate values based on 2 conditions?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/New-at-SAS-Is-it-possible-to-recalculate-values-based-on-2/m-p/23111#M5078</link>
      <description>Add&lt;BR /&gt;
&lt;BR /&gt;
IF first.date THEN r=.;&lt;BR /&gt;
&lt;BR /&gt;
after the computation of r.</description>
      <pubDate>Mon, 17 May 2010 15:58:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/New-at-SAS-Is-it-possible-to-recalculate-values-based-on-2/m-p/23111#M5078</guid>
      <dc:creator>Doc_Duke</dc:creator>
      <dc:date>2010-05-17T15:58:08Z</dc:date>
    </item>
    <item>
      <title>Re: New at SAS, Is it possible to recalculate values based on 2 conditions?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/New-at-SAS-Is-it-possible-to-recalculate-values-based-on-2/m-p/23112#M5079</link>
      <description>Hi:&lt;BR /&gt;
  For a better understanding of the LAG function for future use and to understand why Doc's suggestion will work, these are good resources:&lt;BR /&gt;
    &lt;BR /&gt;
&lt;A href="http://support.sas.com/kb/24/665.html" target="_blank"&gt;http://support.sas.com/kb/24/665.html&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://support.sas.com/resources/papers/proceedings09/055-2009.pdf" target="_blank"&gt;http://support.sas.com/resources/papers/proceedings09/055-2009.pdf&lt;/A&gt; (look at the explanation for table 2a, page 3 in this paper)&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/etsug/63348/HTML/default/viewer.htm#/documentation/cdl/en/etsug/63348/HTML/default/etsug_tsdata_sect048.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/etsug/63348/HTML/default/viewer.htm#/documentation/cdl/en/etsug/63348/HTML/default/etsug_tsdata_sect048.htm&lt;/A&gt; (discussion of the pitfalls of the LAG and DIF functions)&lt;BR /&gt;
      &lt;BR /&gt;
cynthia</description>
      <pubDate>Mon, 17 May 2010 17:15:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/New-at-SAS-Is-it-possible-to-recalculate-values-based-on-2/m-p/23112#M5079</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-05-17T17:15:54Z</dc:date>
    </item>
    <item>
      <title>Re: New at SAS, Is it possible to recalculate values based on 2 conditions?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/New-at-SAS-Is-it-possible-to-recalculate-values-based-on-2/m-p/23113#M5080</link>
      <description>Thanks Doc@Duke for the help, that was exactly what i was looking for and thanks for the links Cynthia@sas.</description>
      <pubDate>Tue, 18 May 2010 12:12:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/New-at-SAS-Is-it-possible-to-recalculate-values-based-on-2/m-p/23113#M5080</guid>
      <dc:creator>adrian_waw</dc:creator>
      <dc:date>2010-05-18T12:12:53Z</dc:date>
    </item>
  </channel>
</rss>

