<?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 How to perform Arithmetic operation on Proc Means Output data? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-perform-Arithmetic-operation-on-Proc-Means-Output-data/m-p/495865#M130979</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data neg_prices;
	set homework_one;
	if price&amp;lt;0 then price_type = 'neg';  * create new label: negative when price is less than zero and otherwise;
	else price_type = 'pos';
run;

proc means data=neg_prices n;a
	class price_type;					 * get number of observations for negative prices;
	var price;
run;
 &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I have a proc means output as shown below:&lt;BR /&gt;I want to extract N from the table and evaluate N for neg/(N for neg + N for pos), pretty much get the proportion of negative data from total data. How to go about this problem?&lt;BR /&gt;SAS Output&lt;/P&gt;&lt;DIV class="branch"&gt;&lt;DIV class="c proctitle"&gt;The MEANS Procedure&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV align="center"&gt;Analysis Variable: Price price_type N Obs N&lt;/DIV&gt;&lt;DIV align="center"&gt;neg 594&lt;/DIV&gt;&lt;DIV align="center"&gt;pos 69478 &lt;TABLE cellspacing="0" cellpadding="5"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;594&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;69478&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Sat, 15 Sep 2018 01:35:58 GMT</pubDate>
    <dc:creator>MUIZVHORA</dc:creator>
    <dc:date>2018-09-15T01:35:58Z</dc:date>
    <item>
      <title>How to perform Arithmetic operation on Proc Means Output data?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-perform-Arithmetic-operation-on-Proc-Means-Output-data/m-p/495865#M130979</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data neg_prices;
	set homework_one;
	if price&amp;lt;0 then price_type = 'neg';  * create new label: negative when price is less than zero and otherwise;
	else price_type = 'pos';
run;

proc means data=neg_prices n;a
	class price_type;					 * get number of observations for negative prices;
	var price;
run;
 &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I have a proc means output as shown below:&lt;BR /&gt;I want to extract N from the table and evaluate N for neg/(N for neg + N for pos), pretty much get the proportion of negative data from total data. How to go about this problem?&lt;BR /&gt;SAS Output&lt;/P&gt;&lt;DIV class="branch"&gt;&lt;DIV class="c proctitle"&gt;The MEANS Procedure&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV align="center"&gt;Analysis Variable: Price price_type N Obs N&lt;/DIV&gt;&lt;DIV align="center"&gt;neg 594&lt;/DIV&gt;&lt;DIV align="center"&gt;pos 69478 &lt;TABLE cellspacing="0" cellpadding="5"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;594&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;69478&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Sat, 15 Sep 2018 01:35:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-perform-Arithmetic-operation-on-Proc-Means-Output-data/m-p/495865#M130979</guid>
      <dc:creator>MUIZVHORA</dc:creator>
      <dc:date>2018-09-15T01:35:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to perform Arithmetic operation on Proc Means Output data?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-perform-Arithmetic-operation-on-Proc-Means-Output-data/m-p/495878#M130987</link>
      <description>&lt;P&gt;You need to direct your output to a data set and then you can use it in further steps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*Create summary statistics for a dataset by a 'grouping' variable and store it in a dataset;

*Generate sample fake data;
data have;
	input ID          feature1         feature2         feature3;
	cards;
1               7.72               5.43              4.35
1               5.54               2.25              8.22 
1               4.43               6.75              2.22
1               3.22               3.21              7.31
2               6.72               2.86              6.11
2               5.89               4.25              5.25 
2               3.43               7.30              8.21
2               1.22               3.55              6.55

;
run;

*Create summary data;
proc means data=have noprint;
	by id;
	var feature1-feature3;
	output out=want median= var= mean= /autoname;
run;

*Show for display;
proc print data=want;
run;

*First done here:https://communities.sas.com/t5/General-SAS-Programming/Getting-creating-new-summary-variables-longitudinal-data/m-p/347940/highlight/false#M44842;
*Another way to present data is as follows;

proc means data=have stackods nway n min max mean median std p5 p95;
    by id;
    var feature1-feature3;
    ods output summary=want2;
run;

*Show for display;
proc print data=want2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Though, PROC FREQ is more suited to what you want, not PROC MEANS.&lt;/P&gt;
&lt;P&gt;This generates an output data set called WANT_FREQ. It should generate the percents as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=sashelp.class;
table price_type /out=want_freq;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 15 Sep 2018 02:35:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-perform-Arithmetic-operation-on-Proc-Means-Output-data/m-p/495878#M130987</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-09-15T02:35:17Z</dc:date>
    </item>
  </channel>
</rss>

