<?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: Summing up the variables in SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Summing-up-the-variables-in-SAS/m-p/259391#M50190</link>
    <description>&lt;P&gt;Please try this one. While creating data set just added totalsales variable to use that in proc tabulate.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data sales;&lt;BR /&gt;input year formulation$ drug$ country$ jan feb mar;&lt;BR /&gt;&lt;STRONG&gt;totalsales=jan+feb+mar;&lt;/STRONG&gt;&lt;BR /&gt;datalines;&lt;BR /&gt;2007 liters xyz1.2 US 120 111 134&lt;BR /&gt;2007 liters xyz1.8 US 129 122 124&lt;BR /&gt;2007 vials xyz1.2 US 123 132 122&lt;BR /&gt;2007 liters xyz1.8 US 122 111 164&lt;BR /&gt;2008 vials xyz1.2 US 133 156 178&lt;BR /&gt;2008 vials xyz1.8 US 122 123 126&lt;BR /&gt;2008 vials xyz1.2 US 124 125 167&lt;BR /&gt;2008 liters xyz1.8 US 134 125 156&lt;BR /&gt;2009 vials xyz1.2 US 124 136 234&lt;BR /&gt;2009 liters xyz1.8 US 134 125 238&lt;BR /&gt;2009 vials xyz1.2 US 123 134 135&lt;BR /&gt;2009 liters xyz1.8 US 126 345 138&lt;BR /&gt;;&lt;BR /&gt;proc tabulate data=sales;&lt;BR /&gt;class year formulation drug;&lt;BR /&gt;var totalsales;&lt;BR /&gt;table year, drug=''*totalsales=''*sum=''*f=8.0 totalsales*all=''*sum=''*f=8.0;&lt;BR /&gt;run;&lt;/P&gt;</description>
    <pubDate>Mon, 28 Mar 2016 17:14:58 GMT</pubDate>
    <dc:creator>stat_sas</dc:creator>
    <dc:date>2016-03-28T17:14:58Z</dc:date>
    <item>
      <title>Summing up the variables in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summing-up-the-variables-in-SAS/m-p/259382#M50185</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a sample dataset&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sales;
input year formulation$ drug$ country$ jan feb mar;
datalines;
2007 liters xyz1.2 US 120 111 134
2007 liters xyz1.8 US 129 122 124
2007 vials  xyz1.2 US 123 132 122
2007 liters xyz1.8 US 122 111 164
2008 vials  xyz1.2 US 133 156 178
2008 vials  xyz1.8 US 122 123 126
2008 vials  xyz1.2 US 124 125 167
2008 liters xyz1.8 US 134 125 156
2009 vials  xyz1.2 US 124 136 234
2009 liters xyz1.8 US 134 125 238
2009 vials  xyz1.2 US 123 134 135
2009 liters xyz1.8 US 126 345 138
;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My output should look like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;year &amp;nbsp;xyz1.2 &amp;nbsp;xyz1.8 &amp;nbsp; totalsales&lt;/P&gt;&lt;P&gt;2007 &amp;nbsp; &amp;nbsp; &amp;nbsp;742 &amp;nbsp; &amp;nbsp; 772 &amp;nbsp; &amp;nbsp; &amp;nbsp; 1514&lt;/P&gt;&lt;P&gt;2008 &amp;nbsp; &amp;nbsp; &amp;nbsp;883 &amp;nbsp; &amp;nbsp; 786 &amp;nbsp; &amp;nbsp; &amp;nbsp; 1669&lt;/P&gt;&lt;P&gt;2009 &amp;nbsp; &amp;nbsp; &amp;nbsp;886 &amp;nbsp; &amp;nbsp;1106 &amp;nbsp; &amp;nbsp; &amp;nbsp;1992&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How should I code the above sample dataset in order to get this output. Please guide me.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Mon, 28 Mar 2016 16:45:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summing-up-the-variables-in-SAS/m-p/259382#M50185</guid>
      <dc:creator>danwarags</dc:creator>
      <dc:date>2016-03-28T16:45:37Z</dc:date>
    </item>
    <item>
      <title>Re: Summing up the variables in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summing-up-the-variables-in-SAS/m-p/259387#M50189</link>
      <description>&lt;P&gt;Should your output be a SAS data set, or should it be a report?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Mar 2016 16:58:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summing-up-the-variables-in-SAS/m-p/259387#M50189</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-03-28T16:58:37Z</dc:date>
    </item>
    <item>
      <title>Re: Summing up the variables in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summing-up-the-variables-in-SAS/m-p/259391#M50190</link>
      <description>&lt;P&gt;Please try this one. While creating data set just added totalsales variable to use that in proc tabulate.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data sales;&lt;BR /&gt;input year formulation$ drug$ country$ jan feb mar;&lt;BR /&gt;&lt;STRONG&gt;totalsales=jan+feb+mar;&lt;/STRONG&gt;&lt;BR /&gt;datalines;&lt;BR /&gt;2007 liters xyz1.2 US 120 111 134&lt;BR /&gt;2007 liters xyz1.8 US 129 122 124&lt;BR /&gt;2007 vials xyz1.2 US 123 132 122&lt;BR /&gt;2007 liters xyz1.8 US 122 111 164&lt;BR /&gt;2008 vials xyz1.2 US 133 156 178&lt;BR /&gt;2008 vials xyz1.8 US 122 123 126&lt;BR /&gt;2008 vials xyz1.2 US 124 125 167&lt;BR /&gt;2008 liters xyz1.8 US 134 125 156&lt;BR /&gt;2009 vials xyz1.2 US 124 136 234&lt;BR /&gt;2009 liters xyz1.8 US 134 125 238&lt;BR /&gt;2009 vials xyz1.2 US 123 134 135&lt;BR /&gt;2009 liters xyz1.8 US 126 345 138&lt;BR /&gt;;&lt;BR /&gt;proc tabulate data=sales;&lt;BR /&gt;class year formulation drug;&lt;BR /&gt;var totalsales;&lt;BR /&gt;table year, drug=''*totalsales=''*sum=''*f=8.0 totalsales*all=''*sum=''*f=8.0;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Mar 2016 17:14:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summing-up-the-variables-in-SAS/m-p/259391#M50190</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2016-03-28T17:14:58Z</dc:date>
    </item>
    <item>
      <title>Re: Summing up the variables in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summing-up-the-variables-in-SAS/m-p/259394#M50191</link>
      <description>proc sql;&lt;BR /&gt;	Select year&lt;BR /&gt;			,sum(xyz1_2) as xyz1_2&lt;BR /&gt;			,sum(xyz1_8) as xyz1_8&lt;BR /&gt;			,sum(totalsales) as totalsales&lt;BR /&gt;	FROM (select year&lt;BR /&gt;				,sum(jan,feb,mar) as totalsales&lt;BR /&gt;				,(CASE when drug='xyz1.2' then calculated totalsales&lt;BR /&gt;						else 0 end) AS xyz1_2&lt;BR /&gt;				,(CASE when drug='xyz1.8' then calculated totalsales&lt;BR /&gt;						else 0 end) AS xyz1_8&lt;BR /&gt;			from sales&lt;BR /&gt;			group by year&lt;BR /&gt;			)&lt;BR /&gt;	GROUP BY year&lt;BR /&gt;	ORDER BY year;&lt;BR /&gt;quit;</description>
      <pubDate>Mon, 28 Mar 2016 17:19:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summing-up-the-variables-in-SAS/m-p/259394#M50191</guid>
      <dc:creator>AhmedAl_Attar</dc:creator>
      <dc:date>2016-03-28T17:19:47Z</dc:date>
    </item>
    <item>
      <title>Re: Summing up the variables in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summing-up-the-variables-in-SAS/m-p/259561#M50223</link>
      <description>&lt;PRE&gt;

data sales;
input year formulation$ drug$ country$ jan feb mar;
datalines;
2007 liters xyz1.2 US 120 111 134
2007 liters xyz1.8 US 129 122 124
2007 vials  xyz1.2 US 123 132 122
2007 liters xyz1.8 US 122 111 164
2008 vials  xyz1.2 US 133 156 178
2008 vials  xyz1.8 US 122 123 126
2008 vials  xyz1.2 US 124 125 167
2008 liters xyz1.8 US 134 125 156
2009 vials  xyz1.2 US 124 136 234
2009 liters xyz1.8 US 134 125 238
2009 vials  xyz1.2 US 123 134 135
2009 liters xyz1.8 US 126 345 138
;
run;
proc sql;
create table temp as
 select *,sum(sum) as totalsales
  from (
   select year,drug,sum(sum(jan,feb,mar)) as sum
    from sales
     group by year,drug
  )
   group by year ;
quit;
proc transpose data=temp out=want(drop=_name_);
 by year totalsales;
 var sum;
 id drug;
 idlabel drug;
run;


&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Mar 2016 02:23:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summing-up-the-variables-in-SAS/m-p/259561#M50223</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-03-29T02:23:08Z</dc:date>
    </item>
  </channel>
</rss>

