<?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: how derive average and insert into a dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-derive-average-and-insert-into-a-dataset/m-p/481350#M124491</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want(drop = n sumsale);
set fi;
by id;
if first.id then do; 
n = 0; 
sumsale = 0;
end;
n +1;
sumsale + sale;
output;
if last.id &amp;amp; month = 2 then do;
month=3;
sale = sumsale/n;
output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 26 Jul 2018 06:24:13 GMT</pubDate>
    <dc:creator>s_manoj</dc:creator>
    <dc:date>2018-07-26T06:24:13Z</dc:date>
    <item>
      <title>how derive average and insert into a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-derive-average-and-insert-into-a-dataset/m-p/481341#M124482</link>
      <description>&lt;P&gt;data fi ;&lt;BR /&gt;input id $ month sale ;&lt;BR /&gt;cards ;&lt;BR /&gt;111 1 150&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;BR /&gt;&lt;SPAN&gt;111 2 250&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;112 1 200&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;112 2 300&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;112 3 250&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;SPAN&gt;111 1 150&lt;/SPAN&gt;&lt;BR /&gt;111 2 250&lt;/P&gt;&lt;P&gt;111 3 200&lt;BR /&gt;112 1 200&lt;BR /&gt;112 2 300&lt;BR /&gt;112 3 250&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;i want id 111&amp;nbsp; third month sale as average of first and second month like this &amp;nbsp;111&amp;nbsp; 3&amp;nbsp; 200&lt;/P&gt;&lt;P&gt;and insert into a dataset&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jul 2018 04:57:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-derive-average-and-insert-into-a-dataset/m-p/481341#M124482</guid>
      <dc:creator>thanikondharish</dc:creator>
      <dc:date>2018-07-26T04:57:20Z</dc:date>
    </item>
    <item>
      <title>Re: how derive average and insert into a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-derive-average-and-insert-into-a-dataset/m-p/481342#M124483</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/209685"&gt;@thanikondharish&lt;/a&gt;&amp;nbsp;do you only have sets of 2 or 3 for each id in your dataset? and is it consistent you want the 3rd month where not available?&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jul 2018 05:04:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-derive-average-and-insert-into-a-dataset/m-p/481342#M124483</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-07-26T05:04:12Z</dc:date>
    </item>
    <item>
      <title>Re: how derive average and insert into a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-derive-average-and-insert-into-a-dataset/m-p/481344#M124485</link>
      <description>first id group of third month sale is missing so i want to fill up third&lt;BR /&gt;month as average of 1 and 2 month and that record insert into a same dataset</description>
      <pubDate>Thu, 26 Jul 2018 05:26:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-derive-average-and-insert-into-a-dataset/m-p/481344#M124485</guid>
      <dc:creator>thanikondharish</dc:creator>
      <dc:date>2018-07-26T05:26:42Z</dc:date>
    </item>
    <item>
      <title>Re: how derive average and insert into a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-derive-average-and-insert-into-a-dataset/m-p/481345#M124486</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data fi ;
input id $ month sale ;
cards ;
111 1 150                                         
111 2 250
112 1 200
112 2 300
112 3 250
;

data want;
array t(100) _temporary_;
call missing(of t(*));
do _n_=1 by 1 until(last.id);
set fi;
by id month;
t(_n_)=sale;
output;
if last.id and month=2 then do;
month=3;
sale=mean(of t(*));
output;
end;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 26 Jul 2018 05:42:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-derive-average-and-insert-into-a-dataset/m-p/481345#M124486</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-07-26T05:42:45Z</dc:date>
    </item>
    <item>
      <title>Re: how derive average and insert into a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-derive-average-and-insert-into-a-dataset/m-p/481350#M124491</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want(drop = n sumsale);
set fi;
by id;
if first.id then do; 
n = 0; 
sumsale = 0;
end;
n +1;
sumsale + sale;
output;
if last.id &amp;amp; month = 2 then do;
month=3;
sale = sumsale/n;
output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 26 Jul 2018 06:24:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-derive-average-and-insert-into-a-dataset/m-p/481350#M124491</guid>
      <dc:creator>s_manoj</dc:creator>
      <dc:date>2018-07-26T06:24:13Z</dc:date>
    </item>
    <item>
      <title>Re: how derive average and insert into a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-derive-average-and-insert-into-a-dataset/m-p/481351#M124492</link>
      <description>You mentioned month=2 in arrays but in some cases different groups have&lt;BR /&gt;different months then what will we do?</description>
      <pubDate>Thu, 26 Jul 2018 06:25:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-derive-average-and-insert-into-a-dataset/m-p/481351#M124492</guid>
      <dc:creator>thanikondharish</dc:creator>
      <dc:date>2018-07-26T06:25:42Z</dc:date>
    </item>
    <item>
      <title>Re: how derive average and insert into a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-derive-average-and-insert-into-a-dataset/m-p/481352#M124493</link>
      <description>&lt;P&gt;Please provide a better and complete sample.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thats the reason i asked earlier "&lt;SPAN&gt;Hi&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://communities.sas.com/t5/user/viewprofilepage/user-id/209685" target="_blank"&gt;@thanikondharish&lt;/A&gt;&lt;SPAN&gt;&lt;EM&gt;&lt;STRONG&gt;&amp;nbsp;do you only have sets of 2 or 3 for each id in your&lt;/STRONG&gt;&lt;/EM&gt; dataset? and is it consistent you want the 3rd month where not available?"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;You didn't clarify&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I hope you understood what im asking&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jul 2018 06:33:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-derive-average-and-insert-into-a-dataset/m-p/481352#M124493</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-07-26T06:33:07Z</dc:date>
    </item>
    <item>
      <title>Re: how derive average and insert into a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-derive-average-and-insert-into-a-dataset/m-p/481353#M124494</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/209685"&gt;@thanikondharish&lt;/a&gt;&lt;BR /&gt;As per your wordings, we understand that you need an average for the third month, so month =2 has been mentioned. Please specify your requirement clearly with sample output</description>
      <pubDate>Thu, 26 Jul 2018 06:33:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-derive-average-and-insert-into-a-dataset/m-p/481353#M124494</guid>
      <dc:creator>s_manoj</dc:creator>
      <dc:date>2018-07-26T06:33:51Z</dc:date>
    </item>
    <item>
      <title>Re: how derive average and insert into a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-derive-average-and-insert-into-a-dataset/m-p/481356#M124495</link>
      <description>data s ;&lt;BR /&gt;input id $ month sale ;&lt;BR /&gt;cards ;&lt;BR /&gt;111 1 450&lt;BR /&gt;111 2 870&lt;BR /&gt;111 3 485&lt;BR /&gt;112 1 485&lt;BR /&gt;112 2 478&lt;BR /&gt;112 3 784&lt;BR /&gt;112 4 784&lt;BR /&gt;113 1 789&lt;BR /&gt;113 2 789&lt;BR /&gt;;&lt;BR /&gt;&lt;BR /&gt;i want every 3rd and 4th month sale but in this data only one group has 4th&lt;BR /&gt;month so remaining groups haven't 4th month sales . So first of all we get&lt;BR /&gt;average of before months and that value assign to 4th month</description>
      <pubDate>Thu, 26 Jul 2018 06:40:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-derive-average-and-insert-into-a-dataset/m-p/481356#M124495</guid>
      <dc:creator>thanikondharish</dc:creator>
      <dc:date>2018-07-26T06:40:42Z</dc:date>
    </item>
    <item>
      <title>Re: how derive average and insert into a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-derive-average-and-insert-into-a-dataset/m-p/481357#M124496</link>
      <description>data s ;&lt;BR /&gt;input id $ month sale ;&lt;BR /&gt;cards ;&lt;BR /&gt;111 1 450&lt;BR /&gt;111 2 870&lt;BR /&gt;111 3 485&lt;BR /&gt;112 1 485&lt;BR /&gt;112 2 478&lt;BR /&gt;112 3 784&lt;BR /&gt;112 4 784&lt;BR /&gt;113 1 789&lt;BR /&gt;113 2 789&lt;BR /&gt;;&lt;BR /&gt;&lt;BR /&gt;i want 4th month sale in every group but in some groups haven't 4th month&lt;BR /&gt;sale.So first of all we need to get the average of 1th,2nd,3rd months and&lt;BR /&gt;that value assign to 4th month and one more question first off all how to&lt;BR /&gt;find which months are missed</description>
      <pubDate>Thu, 26 Jul 2018 06:46:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-derive-average-and-insert-into-a-dataset/m-p/481357#M124496</guid>
      <dc:creator>thanikondharish</dc:creator>
      <dc:date>2018-07-26T06:46:42Z</dc:date>
    </item>
  </channel>
</rss>

