<?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 proc means - creating a new column/ variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-means-creating-a-new-column-variable/m-p/423926#M104304</link>
    <description>&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;Question 1 --In i my data i have the columns - probability and Budget.&lt;/P&gt;&lt;P&gt;I want to group the data by probability and get sum of budget = Total budget for each probability level.&lt;/P&gt;&lt;P&gt;I also want a variable named foretasted Budget which which has product of total budget and probability&lt;/P&gt;&lt;P&gt;&amp;nbsp;how do i get this with proc means.?&lt;/P&gt;&lt;P&gt;My half written code-&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data = c1.od noprint nonobs;
var  Total_Media_Value ;
class _probability___/ descending;
output out=data (drop = _TYPE_ _FREQ_)
sum = Total_Budget
n= num_of_optys;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Question 2-- in the output i am getting a row which gives me total of columns. I want to give&amp;nbsp; that row a name - Total , how do i do that?&lt;/P&gt;&lt;P&gt;eg- my result looks like this -&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;probability&amp;nbsp; total budget&amp;nbsp; num&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;1	.	3200531	361
2	100	68100	7
3	90	56000	4
4	70	23200	8
5	50	156500	18
6	30	112000	5
7	10	2784731	319&lt;/CODE&gt;&lt;/PRE&gt;&lt;DIV class=" dgrid-row dgrid-row-even ui-state-default"&gt;&lt;BR /&gt;i want the first row at the end and have it named total&lt;/DIV&gt;</description>
    <pubDate>Thu, 28 Dec 2017 17:10:47 GMT</pubDate>
    <dc:creator>riya275</dc:creator>
    <dc:date>2017-12-28T17:10:47Z</dc:date>
    <item>
      <title>proc means - creating a new column/ variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-means-creating-a-new-column-variable/m-p/423926#M104304</link>
      <description>&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;Question 1 --In i my data i have the columns - probability and Budget.&lt;/P&gt;&lt;P&gt;I want to group the data by probability and get sum of budget = Total budget for each probability level.&lt;/P&gt;&lt;P&gt;I also want a variable named foretasted Budget which which has product of total budget and probability&lt;/P&gt;&lt;P&gt;&amp;nbsp;how do i get this with proc means.?&lt;/P&gt;&lt;P&gt;My half written code-&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data = c1.od noprint nonobs;
var  Total_Media_Value ;
class _probability___/ descending;
output out=data (drop = _TYPE_ _FREQ_)
sum = Total_Budget
n= num_of_optys;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Question 2-- in the output i am getting a row which gives me total of columns. I want to give&amp;nbsp; that row a name - Total , how do i do that?&lt;/P&gt;&lt;P&gt;eg- my result looks like this -&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;probability&amp;nbsp; total budget&amp;nbsp; num&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;1	.	3200531	361
2	100	68100	7
3	90	56000	4
4	70	23200	8
5	50	156500	18
6	30	112000	5
7	10	2784731	319&lt;/CODE&gt;&lt;/PRE&gt;&lt;DIV class=" dgrid-row dgrid-row-even ui-state-default"&gt;&lt;BR /&gt;i want the first row at the end and have it named total&lt;/DIV&gt;</description>
      <pubDate>Thu, 28 Dec 2017 17:10:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-means-creating-a-new-column-variable/m-p/423926#M104304</guid>
      <dc:creator>riya275</dc:creator>
      <dc:date>2017-12-28T17:10:47Z</dc:date>
    </item>
    <item>
      <title>Re: proc means - creating a new column/ variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-means-creating-a-new-column-variable/m-p/423931#M104307</link>
      <description>&lt;P&gt;Since you re-posted Question 2 separately, I'll give you an answer to just Question 1 here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You're asking to calculate a new variable, and add it&amp;nbsp;to an existing data set.&amp;nbsp; PROC MEANS won't do that, but a DATA step can do that easily.&amp;nbsp; For example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set data;&lt;/P&gt;
&lt;P&gt;forecasted_budget = total_budget * _probability___&amp;nbsp;;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's not clear if you want that as the result, or if you should be dividing by 100.&amp;nbsp; But the formula is up to you.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Dec 2017 17:39:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-means-creating-a-new-column-variable/m-p/423931#M104307</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-12-28T17:39:21Z</dc:date>
    </item>
  </channel>
</rss>

