<?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: subtract the observations with in variable in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/subtract-the-observations-with-in-variable/m-p/31195#M7400</link>
    <description>Hi SBB,&lt;BR /&gt;
Thanks for your help. I found the answer. I just used the dif function.&lt;BR /&gt;
&lt;BR /&gt;
data cctest1;&lt;BR /&gt;
set cctest;&lt;BR /&gt;
 tix06=dif(tix_sold_in_06);&lt;BR /&gt;
 tix07=dif(tix_sold_in_07);&lt;BR /&gt;
 tix08=dif(tix_sold_in_08);&lt;BR /&gt;
 if tix06 eq . then tix06=tix_sold_in_06;&lt;BR /&gt;
 if tix07 eq . then tix07=tix_sold_in_07;&lt;BR /&gt;
 if tix08 eq . then tix08=tix_sold_in_08;&lt;BR /&gt;
 run;&lt;BR /&gt;
&lt;BR /&gt;
Thanks for your thought&lt;BR /&gt;
&lt;BR /&gt;
sams</description>
    <pubDate>Wed, 13 May 2009 14:55:14 GMT</pubDate>
    <dc:creator>ssas</dc:creator>
    <dc:date>2009-05-13T14:55:14Z</dc:date>
    <item>
      <title>subtract the observations with in variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/subtract-the-observations-with-in-variable/m-p/31193#M7398</link>
      <description>Hi i need some help to find how to subtract with in the variable. here is the sample data&lt;BR /&gt;
&lt;BR /&gt;
name   x1     x2     x3&lt;BR /&gt;
wk1     15    35      18&lt;BR /&gt;
wk2     36    48       29&lt;BR /&gt;
wk3     47    56      68&lt;BR /&gt;
wk4     47    58      91&lt;BR /&gt;
wk5    56     79     125&lt;BR /&gt;
wk6    84     96     175&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
i would like to get the out like in the a1 ( wk2.x1-wk1.x1...) a2 ( wk2.x2-wk1.x2)  a3 ( wk2.x3-wk1.x3)&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
name   x1     x2     x3       a1   a2    a3&lt;BR /&gt;
wk1     15    35      18      15     35    18&lt;BR /&gt;
wk2     36    48       29     21(36-15)     13 (48-35)     11(29-18)    &lt;BR /&gt;
wk3     47    56      68     16 (47-36)      8 (56-48)     39 (68-29)&lt;BR /&gt;
wk4     47    58      91     0 (47-47)       2 (58-56)      23 (91-68)&lt;BR /&gt;
wk5    56     79     125&lt;BR /&gt;
wk6    84     96     175&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Thanks in-advance&lt;BR /&gt;
sams</description>
      <pubDate>Wed, 13 May 2009 13:00:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/subtract-the-observations-with-in-variable/m-p/31193#M7398</guid>
      <dc:creator>ssas</dc:creator>
      <dc:date>2009-05-13T13:00:24Z</dc:date>
    </item>
    <item>
      <title>Re: subtract the observations with in variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/subtract-the-observations-with-in-variable/m-p/31194#M7399</link>
      <description>Investigate using the DATA step and the LAG function, along with a sorted file and the BY statement so you can test IF FIRST.NAME THEN DO;  END;  in your DATA step and doing the subtraction correctly on all but the first observation in a BY group.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Wed, 13 May 2009 13:21:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/subtract-the-observations-with-in-variable/m-p/31194#M7399</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-05-13T13:21:41Z</dc:date>
    </item>
    <item>
      <title>Re: subtract the observations with in variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/subtract-the-observations-with-in-variable/m-p/31195#M7400</link>
      <description>Hi SBB,&lt;BR /&gt;
Thanks for your help. I found the answer. I just used the dif function.&lt;BR /&gt;
&lt;BR /&gt;
data cctest1;&lt;BR /&gt;
set cctest;&lt;BR /&gt;
 tix06=dif(tix_sold_in_06);&lt;BR /&gt;
 tix07=dif(tix_sold_in_07);&lt;BR /&gt;
 tix08=dif(tix_sold_in_08);&lt;BR /&gt;
 if tix06 eq . then tix06=tix_sold_in_06;&lt;BR /&gt;
 if tix07 eq . then tix07=tix_sold_in_07;&lt;BR /&gt;
 if tix08 eq . then tix08=tix_sold_in_08;&lt;BR /&gt;
 run;&lt;BR /&gt;
&lt;BR /&gt;
Thanks for your thought&lt;BR /&gt;
&lt;BR /&gt;
sams</description>
      <pubDate>Wed, 13 May 2009 14:55:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/subtract-the-observations-with-in-variable/m-p/31195#M7400</guid>
      <dc:creator>ssas</dc:creator>
      <dc:date>2009-05-13T14:55:14Z</dc:date>
    </item>
  </channel>
</rss>

