<?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 Goal is to drag the column upward without affecting the last observation an in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Goal-is-to-drag-the-column-upward-without-affecting-the-last/m-p/51691#M14181</link>
    <description>I have 3 rates data which are given below&lt;BR /&gt;
rate1	rate2	rate3&lt;BR /&gt;
40	.	.&lt;BR /&gt;
55	343	.&lt;BR /&gt;
55	36	46&lt;BR /&gt;
56	577	57&lt;BR /&gt;
55	35	57&lt;BR /&gt;
55	757	456&lt;BR /&gt;
55	577	246&lt;BR /&gt;
5	474	346&lt;BR /&gt;
Goal is to drag the column upward without affecting the last observation and finding the row wise averages.&lt;BR /&gt;
rate1	rate2	rate3	Averages&lt;BR /&gt;
40	343	46	143.00&lt;BR /&gt;
55	36	57	49 .33&lt;BR /&gt;
55	577	57	229.67&lt;BR /&gt;
56	35	456	182.33&lt;BR /&gt;
55	757	246	352.67&lt;BR /&gt;
55	577	.	316.00&lt;BR /&gt;
55	.	.	55.00&lt;BR /&gt;
5	474	346	&lt;BR /&gt;
I have been successful to certain extent. I feel there is definite need to make it more compact and if there is easier way to handle this situation then please do share the same:&lt;BR /&gt;
data rate1;&lt;BR /&gt;
input rate1;&lt;BR /&gt;
datalines;&lt;BR /&gt;
40&lt;BR /&gt;
55&lt;BR /&gt;
55&lt;BR /&gt;
56&lt;BR /&gt;
55&lt;BR /&gt;
55&lt;BR /&gt;
55&lt;BR /&gt;
5&lt;BR /&gt;
;&lt;BR /&gt;
data rate2;&lt;BR /&gt;
input rate2;&lt;BR /&gt;
datalines;&lt;BR /&gt;
.&lt;BR /&gt;
343&lt;BR /&gt;
36&lt;BR /&gt;
577&lt;BR /&gt;
35&lt;BR /&gt;
757&lt;BR /&gt;
577&lt;BR /&gt;
474&lt;BR /&gt;
;&lt;BR /&gt;
data rate3;&lt;BR /&gt;
input rate3;&lt;BR /&gt;
datalines;&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
46&lt;BR /&gt;
57&lt;BR /&gt;
57&lt;BR /&gt;
456&lt;BR /&gt;
246&lt;BR /&gt;
346&lt;BR /&gt;
;&lt;BR /&gt;
data all_rates;&lt;BR /&gt;
merge rate1 rate2 rate3;&lt;BR /&gt;
run;&lt;BR /&gt;
data lastobservation;&lt;BR /&gt;
set all_rates end=last;&lt;BR /&gt;
if last;&lt;BR /&gt;
run;&lt;BR /&gt;
data rate1;&lt;BR /&gt;
set rate1 end=last;&lt;BR /&gt;
if rate1=. then delete;&lt;BR /&gt;
if last then delete;&lt;BR /&gt;
run;&lt;BR /&gt;
data rate2;&lt;BR /&gt;
set rate2 end=last;&lt;BR /&gt;
if rate2=. then delete;&lt;BR /&gt;
if last then delete;&lt;BR /&gt;
data rate3;&lt;BR /&gt;
set rate3 end=last;&lt;BR /&gt;
if rate3=. then delete;&lt;BR /&gt;
if last  then delete;&lt;BR /&gt;
run;&lt;BR /&gt;
data all_rates_table;&lt;BR /&gt;
merge rate1 rate2 rate3;&lt;BR /&gt;
Averages=mean(rate1, rate2, rate3);&lt;BR /&gt;
run;&lt;BR /&gt;
data final;&lt;BR /&gt;
set all_rates_table lastobservation;&lt;BR /&gt;
run;</description>
    <pubDate>Sun, 17 Apr 2011 02:05:59 GMT</pubDate>
    <dc:creator>Swordfish</dc:creator>
    <dc:date>2011-04-17T02:05:59Z</dc:date>
    <item>
      <title>Goal is to drag the column upward without affecting the last observation an</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Goal-is-to-drag-the-column-upward-without-affecting-the-last/m-p/51691#M14181</link>
      <description>I have 3 rates data which are given below&lt;BR /&gt;
rate1	rate2	rate3&lt;BR /&gt;
40	.	.&lt;BR /&gt;
55	343	.&lt;BR /&gt;
55	36	46&lt;BR /&gt;
56	577	57&lt;BR /&gt;
55	35	57&lt;BR /&gt;
55	757	456&lt;BR /&gt;
55	577	246&lt;BR /&gt;
5	474	346&lt;BR /&gt;
Goal is to drag the column upward without affecting the last observation and finding the row wise averages.&lt;BR /&gt;
rate1	rate2	rate3	Averages&lt;BR /&gt;
40	343	46	143.00&lt;BR /&gt;
55	36	57	49 .33&lt;BR /&gt;
55	577	57	229.67&lt;BR /&gt;
56	35	456	182.33&lt;BR /&gt;
55	757	246	352.67&lt;BR /&gt;
55	577	.	316.00&lt;BR /&gt;
55	.	.	55.00&lt;BR /&gt;
5	474	346	&lt;BR /&gt;
I have been successful to certain extent. I feel there is definite need to make it more compact and if there is easier way to handle this situation then please do share the same:&lt;BR /&gt;
data rate1;&lt;BR /&gt;
input rate1;&lt;BR /&gt;
datalines;&lt;BR /&gt;
40&lt;BR /&gt;
55&lt;BR /&gt;
55&lt;BR /&gt;
56&lt;BR /&gt;
55&lt;BR /&gt;
55&lt;BR /&gt;
55&lt;BR /&gt;
5&lt;BR /&gt;
;&lt;BR /&gt;
data rate2;&lt;BR /&gt;
input rate2;&lt;BR /&gt;
datalines;&lt;BR /&gt;
.&lt;BR /&gt;
343&lt;BR /&gt;
36&lt;BR /&gt;
577&lt;BR /&gt;
35&lt;BR /&gt;
757&lt;BR /&gt;
577&lt;BR /&gt;
474&lt;BR /&gt;
;&lt;BR /&gt;
data rate3;&lt;BR /&gt;
input rate3;&lt;BR /&gt;
datalines;&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
46&lt;BR /&gt;
57&lt;BR /&gt;
57&lt;BR /&gt;
456&lt;BR /&gt;
246&lt;BR /&gt;
346&lt;BR /&gt;
;&lt;BR /&gt;
data all_rates;&lt;BR /&gt;
merge rate1 rate2 rate3;&lt;BR /&gt;
run;&lt;BR /&gt;
data lastobservation;&lt;BR /&gt;
set all_rates end=last;&lt;BR /&gt;
if last;&lt;BR /&gt;
run;&lt;BR /&gt;
data rate1;&lt;BR /&gt;
set rate1 end=last;&lt;BR /&gt;
if rate1=. then delete;&lt;BR /&gt;
if last then delete;&lt;BR /&gt;
run;&lt;BR /&gt;
data rate2;&lt;BR /&gt;
set rate2 end=last;&lt;BR /&gt;
if rate2=. then delete;&lt;BR /&gt;
if last then delete;&lt;BR /&gt;
data rate3;&lt;BR /&gt;
set rate3 end=last;&lt;BR /&gt;
if rate3=. then delete;&lt;BR /&gt;
if last  then delete;&lt;BR /&gt;
run;&lt;BR /&gt;
data all_rates_table;&lt;BR /&gt;
merge rate1 rate2 rate3;&lt;BR /&gt;
Averages=mean(rate1, rate2, rate3);&lt;BR /&gt;
run;&lt;BR /&gt;
data final;&lt;BR /&gt;
set all_rates_table lastobservation;&lt;BR /&gt;
run;</description>
      <pubDate>Sun, 17 Apr 2011 02:05:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Goal-is-to-drag-the-column-upward-without-affecting-the-last/m-p/51691#M14181</guid>
      <dc:creator>Swordfish</dc:creator>
      <dc:date>2011-04-17T02:05:59Z</dc:date>
    </item>
    <item>
      <title>Re: Goal is to drag the column upward without affecting the last observation an</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Goal-is-to-drag-the-column-upward-without-affecting-the-last/m-p/51692#M14182</link>
      <description>There are probably numerous ways of doing what you want.  One possibility might be:&lt;BR /&gt;
&lt;BR /&gt;
data want (keep=rate: averages);&lt;BR /&gt;
  set have nobs=nobs;&lt;BR /&gt;
  current_rec=_n_;&lt;BR /&gt;
  set have ( firstobs = 2 keep = rate2 rename = (rate2 = Next2) )&lt;BR /&gt;
      have (      obs = 1 drop = _all_                          );&lt;BR /&gt;
  set have ( firstobs = 3 keep = rate3 rename = (rate3 = Next3) )&lt;BR /&gt;
      have (      obs = 1 drop = _all_                          )&lt;BR /&gt;
      have (      obs = 1 drop = _all_                          );&lt;BR /&gt;
  rate2 = ifn( current_rec eq nobs,rate2,&lt;BR /&gt;
           ifn(current_rec lt nobs-1, Next2,(.)));&lt;BR /&gt;
  rate3 = ifn( current_rec eq nobs,rate3,&lt;BR /&gt;
           ifn(current_rec lt nobs-2, Next3,(.)));&lt;BR /&gt;
  averages=ifn( current_rec lt nobs,mean(of rate:),(.));&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
HTH,&lt;BR /&gt;
Art&lt;BR /&gt;
---------&lt;BR /&gt;
&amp;gt; I have 3 rates data which are given below&lt;BR /&gt;
&amp;gt; rate1	rate2	rate3&lt;BR /&gt;
&amp;gt; 40	.	.&lt;BR /&gt;
&amp;gt; 55	343	.&lt;BR /&gt;
&amp;gt; 55	36	46&lt;BR /&gt;
&amp;gt; 56	577	57&lt;BR /&gt;
&amp;gt; 55	35	57&lt;BR /&gt;
&amp;gt; 55	757	456&lt;BR /&gt;
&amp;gt; 55	577	246&lt;BR /&gt;
&amp;gt; 5	474	346&lt;BR /&gt;
&amp;gt; Goal is to drag the column upward without affecting&lt;BR /&gt;
&amp;gt; the last observation and finding the row wise&lt;BR /&gt;
&amp;gt; averages.&lt;BR /&gt;
&amp;gt; rate1	rate2	rate3	Averages&lt;BR /&gt;
&amp;gt; 40	343	46	143.00&lt;BR /&gt;
&amp;gt; 55	36	57	49 .33&lt;BR /&gt;
&amp;gt; 55	577	57	229.67&lt;BR /&gt;
&amp;gt; 56	35	456	182.33&lt;BR /&gt;
&amp;gt; 55	757	246	352.67&lt;BR /&gt;
&amp;gt; 55	577	.	316.00&lt;BR /&gt;
&amp;gt; 55	.	.	55.00&lt;BR /&gt;
&amp;gt; 5	474	346	&lt;BR /&gt;
&amp;gt; I have been successful to certain extent. I feel&lt;BR /&gt;
&amp;gt; there is definite need to make it more compact and if&lt;BR /&gt;
&amp;gt; there is easier way to handle this situation then&lt;BR /&gt;
&amp;gt; please do share the same:&lt;BR /&gt;
&amp;gt; data rate1;&lt;BR /&gt;
&amp;gt; input rate1;&lt;BR /&gt;
&amp;gt; datalines;&lt;BR /&gt;
&amp;gt; 40&lt;BR /&gt;
&amp;gt; 55&lt;BR /&gt;
&amp;gt; 55&lt;BR /&gt;
&amp;gt; 56&lt;BR /&gt;
&amp;gt; 55&lt;BR /&gt;
&amp;gt; 55&lt;BR /&gt;
&amp;gt; 55&lt;BR /&gt;
&amp;gt; 5&lt;BR /&gt;
&amp;gt; ;&lt;BR /&gt;
&amp;gt; data rate2;&lt;BR /&gt;
&amp;gt; input rate2;&lt;BR /&gt;
&amp;gt; datalines;&lt;BR /&gt;
&amp;gt; .&lt;BR /&gt;
&amp;gt; 343&lt;BR /&gt;
&amp;gt; 36&lt;BR /&gt;
&amp;gt; 577&lt;BR /&gt;
&amp;gt; 35&lt;BR /&gt;
&amp;gt; 757&lt;BR /&gt;
&amp;gt; 577&lt;BR /&gt;
&amp;gt; 474&lt;BR /&gt;
&amp;gt; ;&lt;BR /&gt;
&amp;gt; data rate3;&lt;BR /&gt;
&amp;gt; input rate3;&lt;BR /&gt;
&amp;gt; datalines;&lt;BR /&gt;
&amp;gt; .&lt;BR /&gt;
&amp;gt; .&lt;BR /&gt;
&amp;gt; 46&lt;BR /&gt;
&amp;gt; 57&lt;BR /&gt;
&amp;gt; 57&lt;BR /&gt;
&amp;gt; 456&lt;BR /&gt;
&amp;gt; 246&lt;BR /&gt;
&amp;gt; 346&lt;BR /&gt;
&amp;gt; ;&lt;BR /&gt;
&amp;gt; data all_rates;&lt;BR /&gt;
&amp;gt; merge rate1 rate2 rate3;&lt;BR /&gt;
&amp;gt; run;&lt;BR /&gt;
&amp;gt; data lastobservation;&lt;BR /&gt;
&amp;gt; set all_rates end=last;&lt;BR /&gt;
&amp;gt; if last;&lt;BR /&gt;
&amp;gt; run;&lt;BR /&gt;
&amp;gt; data rate1;&lt;BR /&gt;
&amp;gt; set rate1 end=last;&lt;BR /&gt;
&amp;gt; if rate1=. then delete;&lt;BR /&gt;
&amp;gt; if last then delete;&lt;BR /&gt;
&amp;gt; run;&lt;BR /&gt;
&amp;gt; data rate2;&lt;BR /&gt;
&amp;gt; set rate2 end=last;&lt;BR /&gt;
&amp;gt; if rate2=. then delete;&lt;BR /&gt;
&amp;gt; if last then delete;&lt;BR /&gt;
&amp;gt; data rate3;&lt;BR /&gt;
&amp;gt; set rate3 end=last;&lt;BR /&gt;
&amp;gt; if rate3=. then delete;&lt;BR /&gt;
&amp;gt; if last  then delete;&lt;BR /&gt;
&amp;gt; run;&lt;BR /&gt;
&amp;gt; data all_rates_table;&lt;BR /&gt;
&amp;gt; merge rate1 rate2 rate3;&lt;BR /&gt;
&amp;gt; Averages=mean(rate1, rate2, rate3);&lt;BR /&gt;
&amp;gt; run;&lt;BR /&gt;
&amp;gt; data final;&lt;BR /&gt;
&amp;gt; set all_rates_table lastobservation;&lt;BR /&gt;
&amp;gt; run;</description>
      <pubDate>Sun, 17 Apr 2011 18:49:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Goal-is-to-drag-the-column-upward-without-affecting-the-last/m-p/51692#M14182</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-04-17T18:49:15Z</dc:date>
    </item>
    <item>
      <title>Re: Goal is to drag the column upward without affecting the last observation an</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Goal-is-to-drag-the-column-upward-without-affecting-the-last/m-p/51693#M14183</link>
      <description>[pre]&lt;BR /&gt;
data rate1;&lt;BR /&gt;
input rate1;&lt;BR /&gt;
datalines;&lt;BR /&gt;
40&lt;BR /&gt;
55&lt;BR /&gt;
55&lt;BR /&gt;
56&lt;BR /&gt;
55&lt;BR /&gt;
55&lt;BR /&gt;
55&lt;BR /&gt;
5&lt;BR /&gt;
;&lt;BR /&gt;
data rate2;&lt;BR /&gt;
input rate2;&lt;BR /&gt;
datalines;&lt;BR /&gt;
.&lt;BR /&gt;
343&lt;BR /&gt;
36&lt;BR /&gt;
577&lt;BR /&gt;
35&lt;BR /&gt;
757&lt;BR /&gt;
577&lt;BR /&gt;
474&lt;BR /&gt;
;&lt;BR /&gt;
data rate3;&lt;BR /&gt;
input rate3;&lt;BR /&gt;
datalines;&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
46&lt;BR /&gt;
57&lt;BR /&gt;
57&lt;BR /&gt;
456&lt;BR /&gt;
246&lt;BR /&gt;
346&lt;BR /&gt;
;&lt;BR /&gt;
data all_rates;&lt;BR /&gt;
merge rate1 rate2 rate3;&lt;BR /&gt;
run;&lt;BR /&gt;
data temp;&lt;BR /&gt;
set all_rates end=last;&lt;BR /&gt;
if not last;&lt;BR /&gt;
run;&lt;BR /&gt;
data lastobservation;&lt;BR /&gt;
set all_rates end=last;&lt;BR /&gt;
if last;&lt;BR /&gt;
run;&lt;BR /&gt;
data want;&lt;BR /&gt;
 merge temp temp(keep=rate2 rename=(rate2=_rate2) where=(_rate2 is not missing))&lt;BR /&gt;
                 temp(keep=rate3 rename=(rate3=_rate3) where=(_rate3 is not missing));&lt;BR /&gt;
 drop rate2 rate3 ;&lt;BR /&gt;
run;&lt;BR /&gt;
data want;&lt;BR /&gt;
 set want(rename=(_rate2=rate2 _rate3=rate3)) lastobservation;&lt;BR /&gt;
 average=mean(of rate:);&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Mon, 18 Apr 2011 09:33:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Goal-is-to-drag-the-column-upward-without-affecting-the-last/m-p/51693#M14183</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-04-18T09:33:00Z</dc:date>
    </item>
    <item>
      <title>Re: Goal is to drag the column upward without affecting the last observation an</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Goal-is-to-drag-the-column-upward-without-affecting-the-last/m-p/51694#M14184</link>
      <description>Lots of thanks to both Art and Ksharp for their kind help.&lt;BR /&gt;
&lt;BR /&gt;
regards&lt;BR /&gt;
&lt;BR /&gt;
Tony</description>
      <pubDate>Tue, 19 Apr 2011 03:21:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Goal-is-to-drag-the-column-upward-without-affecting-the-last/m-p/51694#M14184</guid>
      <dc:creator>Swordfish</dc:creator>
      <dc:date>2011-04-19T03:21:25Z</dc:date>
    </item>
  </channel>
</rss>

