<?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: proc means result need to show analysis variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-means-result-need-to-show-analysis-variable/m-p/452384#M114172</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/102019"&gt;@paddyb&lt;/a&gt; wrote:&lt;BR /&gt;Thank you.Actually I am calculating proc means for 6 variables so used macro.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In PROC MEANS, put all six variables into the VAR statement.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 08 Apr 2018 23:52:07 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2018-04-08T23:52:07Z</dc:date>
    <item>
      <title>proc means result need to show analysis variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-means-result-need-to-show-analysis-variable/m-p/452371#M114161</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to display&amp;nbsp; statistics with variable .Output is not showing var column.(var=age)what I am missing?&lt;/P&gt;</description>
      <pubDate>Sun, 08 Apr 2018 22:24:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-means-result-need-to-show-analysis-variable/m-p/452371#M114161</guid>
      <dc:creator>paddyb</dc:creator>
      <dc:date>2018-04-08T22:24:53Z</dc:date>
    </item>
    <item>
      <title>Re: proc means result need to show analysis variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-means-result-need-to-show-analysis-variable/m-p/452374#M114164</link>
      <description>&lt;P&gt;VAR is not a variable in your data set. It is a macro variable. Therefore, PROC MEANS cannot output it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 08 Apr 2018 22:39:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-means-result-need-to-show-analysis-variable/m-p/452374#M114164</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-04-08T22:39:02Z</dc:date>
    </item>
    <item>
      <title>Re: proc means result need to show analysis variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-means-result-need-to-show-analysis-variable/m-p/452376#M114166</link>
      <description>&lt;P&gt;&amp;amp;var is a constant value = "age". I see no sense of adding a column with a constant value.&lt;/P&gt;
&lt;P&gt;you can add TITLE to the proc means as:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;STRONG&gt;title "Analysis for &amp;amp;var";&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 08 Apr 2018 22:53:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-means-result-need-to-show-analysis-variable/m-p/452376#M114166</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2018-04-08T22:53:38Z</dc:date>
    </item>
    <item>
      <title>Re: proc means result need to show analysis variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-means-result-need-to-show-analysis-variable/m-p/452380#M114168</link>
      <description>&lt;P&gt;I need var='Age' for creating another dataset from this dataset.I tried adding var=&amp;amp;var in output statementt but its not working&lt;/P&gt;</description>
      <pubDate>Sun, 08 Apr 2018 23:09:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-means-result-need-to-show-analysis-variable/m-p/452380#M114168</guid>
      <dc:creator>paddyb</dc:creator>
      <dc:date>2018-04-08T23:09:04Z</dc:date>
    </item>
    <item>
      <title>Re: proc means result need to show analysis variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-means-result-need-to-show-analysis-variable/m-p/452381#M114169</link>
      <description>&lt;P&gt;If I understand you properly, and I may not be understanding you properly, this should work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data stat_&amp;amp;var;
    set stat_&amp;amp;var;
    var="&amp;amp;var" ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I also get the impression that macros are not needed here, but without seeing the larger picture, I can't know for sure. I get the impression you working hard to get a macro solution when something simpler would work.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the future, please include your SAS code directly in your&amp;nbsp; message (and not as an attachment) by clicking on the "running man" icon and then typing or pasting your code into that window.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 08 Apr 2018 23:30:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-means-result-need-to-show-analysis-variable/m-p/452381#M114169</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-04-08T23:30:45Z</dc:date>
    </item>
    <item>
      <title>Re: proc means result need to show analysis variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-means-result-need-to-show-analysis-variable/m-p/452382#M114170</link>
      <description>Thank you.Actually I am calculating proc means for 6 variables so used macro.</description>
      <pubDate>Sun, 08 Apr 2018 23:38:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-means-result-need-to-show-analysis-variable/m-p/452382#M114170</guid>
      <dc:creator>paddyb</dc:creator>
      <dc:date>2018-04-08T23:38:54Z</dc:date>
    </item>
    <item>
      <title>Re: proc means result need to show analysis variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-means-result-need-to-show-analysis-variable/m-p/452383#M114171</link>
      <description>&lt;P&gt;The method you're using, PROC MEANS + TRANSPOSE is a bit outdated. I prefer using the ODS OUTPUT which includes the variables and statistics in the form you're probably trying to achieve .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=sashelp.cars stackods n mean min max median nway;
class origin make;
var mpg_highway mpg_city length;
ods output summary=want;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Look at the output here, in the WANT table. You can see there's a variable called VARIABLE that has the variable name, and the output by default is already in the format you want. If there's a statistic you want that's not listed, include it in the PROC MEANS statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EDIT: changed example to show it works with multiple variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class="bp-text bp-text-plain hljs"&gt;&lt;CODE class="txt"&gt;%macro contstats(ds=,var=);

proc means data = &amp;amp;ds.  completetypes nway chartype missing noprint  ;
class trt02p/missing mlf;
  var &amp;amp;var;
  output out = stats&amp;amp;var (drop=_type_ _freq_) n=n mean=Mean stddev=SD median=Median min=Min max=Max ;
run;

proc transpose data = stats&amp;amp;var out = stat_&amp;amp;var (drop=_label_);
id trt02p;
run;
%mend contstats;


%contstats(ds=adsl_,var=age);

output I got is
trt02p ,n , mean  , sd ,median  , min ,  max
10 mg	5	31.9	15.39	24.3	18.6	56	
20 mg	5	23.68	6.496	21.9	18.4	34.2	
40 mg	5	22.16	3.502	21.5	18.3	27.1	
80 mg	4	25.325	3.831	24.4	22	30.5

output I want is column var with value age before trt02p.	&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="bp-popup-modal"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/BLOCKQUOTE&gt;
&lt;DIV class="bp-controls-wrapper"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Sun, 08 Apr 2018 23:56:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-means-result-need-to-show-analysis-variable/m-p/452383#M114171</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-04-08T23:56:25Z</dc:date>
    </item>
    <item>
      <title>Re: proc means result need to show analysis variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-means-result-need-to-show-analysis-variable/m-p/452384#M114172</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/102019"&gt;@paddyb&lt;/a&gt; wrote:&lt;BR /&gt;Thank you.Actually I am calculating proc means for 6 variables so used macro.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In PROC MEANS, put all six variables into the VAR statement.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 08 Apr 2018 23:52:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-means-result-need-to-show-analysis-variable/m-p/452384#M114172</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-04-08T23:52:07Z</dc:date>
    </item>
  </channel>
</rss>

