<?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: Mean/Average Value for Dynamic Variables in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Mean-Average-Value-for-Dynamic-Variables/m-p/71207#M20533</link>
    <description>Hello 1239,&lt;BR /&gt;
&lt;BR /&gt;
Look at proc TABULATE or proc REPORT for this purpose. A combination of proc MEANS with a datastep could help too. &lt;BR /&gt;
"I want Average values of Mean or overall Mean value of dynamic variables" it is not very clear. Does it mean that input and output dataset names and variable names have to be parameters to some macro program calculating the overall mean? &lt;BR /&gt;
&lt;BR /&gt;
Sincerely,&lt;BR /&gt;
SPR</description>
    <pubDate>Mon, 30 May 2011 18:23:14 GMT</pubDate>
    <dc:creator>SPR</dc:creator>
    <dc:date>2011-05-30T18:23:14Z</dc:date>
    <item>
      <title>Mean/Average Value for Dynamic Variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Mean-Average-Value-for-Dynamic-Variables/m-p/71206#M20532</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
I want Average values of Mean or overall Mean value of dynamic variables. Variables may vary from project to project. Please some one help.&lt;BR /&gt;
&lt;BR /&gt;
Thanks in Advance.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;B&gt;Data:&lt;/B&gt;&lt;BR /&gt;
--------------------------------------------------&lt;BR /&gt;
Project	Country	T1	T2&lt;BR /&gt;
A	        INDIA	9	8&lt;BR /&gt;
A	        US          	7	6&lt;BR /&gt;
A	        UK          	5	4&lt;BR /&gt;
---------------------------------------------------&lt;BR /&gt;
Project	Country	T1	T2	T4&lt;BR /&gt;
B	        INDIA	1	2	3&lt;BR /&gt;
B	        US	        5	4	7&lt;BR /&gt;
B	        UK	       6	8	9&lt;BR /&gt;
---------------------------------------------------&lt;BR /&gt;
&lt;BR /&gt;
&lt;B&gt;Output Expected:&lt;/B&gt;&lt;BR /&gt;
----------------------------------------------------------------------&lt;BR /&gt;
Project	Country	           T1	 T2&lt;BR /&gt;
A	        INDIA	            9	 8&lt;BR /&gt;
A	        US	                    7	 6&lt;BR /&gt;
A	        UK	                    5	 4&lt;BR /&gt;
	        ALL_COUNTRY	    7	 6&lt;BR /&gt;
----------------------------------------------------------------------&lt;BR /&gt;
&lt;BR /&gt;
Project	Country	           T1	  T2      T4&lt;BR /&gt;
B	        INDIA	            1	  2        3&lt;BR /&gt;
B	        US	                    5	  4        7&lt;BR /&gt;
B	        UK	                    6	  8        9&lt;BR /&gt;
	        ALL_COUNTRY	    4	  4.67   6.33&lt;BR /&gt;
----------------------------------------------------------------------</description>
      <pubDate>Mon, 30 May 2011 13:44:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Mean-Average-Value-for-Dynamic-Variables/m-p/71206#M20532</guid>
      <dc:creator>1239</dc:creator>
      <dc:date>2011-05-30T13:44:18Z</dc:date>
    </item>
    <item>
      <title>Re: Mean/Average Value for Dynamic Variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Mean-Average-Value-for-Dynamic-Variables/m-p/71207#M20533</link>
      <description>Hello 1239,&lt;BR /&gt;
&lt;BR /&gt;
Look at proc TABULATE or proc REPORT for this purpose. A combination of proc MEANS with a datastep could help too. &lt;BR /&gt;
"I want Average values of Mean or overall Mean value of dynamic variables" it is not very clear. Does it mean that input and output dataset names and variable names have to be parameters to some macro program calculating the overall mean? &lt;BR /&gt;
&lt;BR /&gt;
Sincerely,&lt;BR /&gt;
SPR</description>
      <pubDate>Mon, 30 May 2011 18:23:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Mean-Average-Value-for-Dynamic-Variables/m-p/71207#M20533</guid>
      <dc:creator>SPR</dc:creator>
      <dc:date>2011-05-30T18:23:14Z</dc:date>
    </item>
    <item>
      <title>Re: Mean/Average Value for Dynamic Variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Mean-Average-Value-for-Dynamic-Variables/m-p/71208#M20534</link>
      <description>Hi SPR,&lt;BR /&gt;
&lt;BR /&gt;
Actually dynamic variable means for some project variables will be  T1, T2 and for some projects will be T1, T2, T4 so on...&lt;BR /&gt;
&lt;BR /&gt;
T1, T2, T4 these are created from Macro. So this is not constant and it may vary depending on the projects.&lt;BR /&gt;
&lt;BR /&gt;
Currently i need average mean value for T1, T2, T4 so on in the last row as show in the output expected.&lt;BR /&gt;
&lt;BR /&gt;
Please help.</description>
      <pubDate>Tue, 31 May 2011 02:02:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Mean-Average-Value-for-Dynamic-Variables/m-p/71208#M20534</guid>
      <dc:creator>1239</dc:creator>
      <dc:date>2011-05-31T02:02:58Z</dc:date>
    </item>
    <item>
      <title>Re: Mean/Average Value for Dynamic Variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Mean-Average-Value-for-Dynamic-Variables/m-p/71209#M20535</link>
      <description>Hi:&lt;BR /&gt;
  PROC MEANS supports the use of the automatic variable reference _NUMERIC_ -- which might do what you want. You can read about how the _TYPE_ variable is created and how you can use it to determine which variables contributed to the calculated statistics.&lt;BR /&gt;
           &lt;BR /&gt;
At some point, unless you generate the TABULATE or REPORT code with a macro program, you will have to use the variable names or report item names in the code, such as in a TABLE statement or in a DEFINE statement.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia&lt;BR /&gt;
 &lt;BR /&gt;
[pre]&lt;BR /&gt;
  &lt;BR /&gt;
proc means data=sashelp.class mean;&lt;BR /&gt;
  class sex;&lt;BR /&gt;
  var _numeric_;&lt;BR /&gt;
  output out=work.mnout mean=;&lt;BR /&gt;
run;&lt;BR /&gt;
         &lt;BR /&gt;
proc print data=work.mnout;&lt;BR /&gt;
title '_type_ 0 is the overall mean; _type_ 1 is the class variable mean';&lt;BR /&gt;
run;&lt;BR /&gt;
                                            &lt;BR /&gt;
proc means data=sashelp.class mean;&lt;BR /&gt;
  class name;&lt;BR /&gt;
  var _numeric_;&lt;BR /&gt;
  output out=work.namout mean= ;&lt;BR /&gt;
run;&lt;BR /&gt;
                  &lt;BR /&gt;
proc print data=work.namout;&lt;BR /&gt;
title 'Using Name as the CLASS variable';&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Tue, 31 May 2011 02:23:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Mean-Average-Value-for-Dynamic-Variables/m-p/71209#M20535</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2011-05-31T02:23:04Z</dc:date>
    </item>
    <item>
      <title>Re: Mean/Average Value for Dynamic Variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Mean-Average-Value-for-Dynamic-Variables/m-p/71210#M20536</link>
      <description>[pre]&lt;BR /&gt;
&lt;BR /&gt;
data temp;&lt;BR /&gt;
input Project $ Country $ T1 T2 ;&lt;BR /&gt;
cards;&lt;BR /&gt;
A INDIA 9 8&lt;BR /&gt;
A US 7 6&lt;BR /&gt;
A UK 5 4&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
proc summary data=temp ;&lt;BR /&gt;
 var _numeric_;&lt;BR /&gt;
 output out=all_mean(drop=_type_ _freq_) mean= ;&lt;BR /&gt;
run; &lt;BR /&gt;
data want;&lt;BR /&gt;
 set temp end=last;&lt;BR /&gt;
 output;&lt;BR /&gt;
 if last then do;&lt;BR /&gt;
                set all_mean;&lt;BR /&gt;
                country='All_Country';&lt;BR /&gt;
                output;&lt;BR /&gt;
              end;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Tue, 31 May 2011 04:36:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Mean-Average-Value-for-Dynamic-Variables/m-p/71210#M20536</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-05-31T04:36:15Z</dc:date>
    </item>
    <item>
      <title>Re: Mean/Average Value for Dynamic Variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Mean-Average-Value-for-Dynamic-Variables/m-p/71211#M20537</link>
      <description>Hi Ksharp. &lt;BR /&gt;
&lt;BR /&gt;
Thanks for your help. Its working fine but only thing is i need to format it.&lt;BR /&gt;
&lt;BR /&gt;
Currently the output is coming as ALL_COUNTRY 7.766666667 7.166666667&lt;BR /&gt;
so on.&lt;BR /&gt;
&lt;BR /&gt;
I need output as ALL_COUNTRY 7.7 7.1&lt;BR /&gt;
&lt;BR /&gt;
It should not round off but i need only one digit after decimal.&lt;BR /&gt;
&lt;BR /&gt;
I tried adding format but no impact on output. Please help.&lt;BR /&gt;
&lt;BR /&gt;
data temp;&lt;BR /&gt;
input Project $ Country $ T1 T2 ;&lt;BR /&gt;
cards;&lt;BR /&gt;
A INDIA 9 8&lt;BR /&gt;
A US 7 6&lt;BR /&gt;
A UK 5 4&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
proc summary data=temp ;&lt;BR /&gt;
 var _numeric_;&lt;BR /&gt;
 format _numeric_ 8.1;&lt;BR /&gt;
 output out=all_mean(drop=_type_ _freq_) mean= ;&lt;BR /&gt;
run; &lt;BR /&gt;
data want;&lt;BR /&gt;
 set temp end=last;&lt;BR /&gt;
 output;&lt;BR /&gt;
 if last then do;&lt;BR /&gt;
                set all_mean;&lt;BR /&gt;
                country='All_Country';&lt;BR /&gt;
                output;&lt;BR /&gt;
              end;&lt;BR /&gt;
run;</description>
      <pubDate>Tue, 31 May 2011 06:55:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Mean-Average-Value-for-Dynamic-Variables/m-p/71211#M20537</guid>
      <dc:creator>1239</dc:creator>
      <dc:date>2011-05-31T06:55:16Z</dc:date>
    </item>
    <item>
      <title>Re: Mean/Average Value for Dynamic Variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Mean-Average-Value-for-Dynamic-Variables/m-p/71212#M20538</link>
      <description>Hello 1239,&lt;BR /&gt;
&lt;BR /&gt;
This is a solution:&lt;BR /&gt;
[pre]&lt;BR /&gt;
data i;&lt;BR /&gt;
input Project $ Country $ T1 T2;&lt;BR /&gt;
datalines;&lt;BR /&gt;
A INDIA 9 8&lt;BR /&gt;
A US 7 6&lt;BR /&gt;
A UK 5 4&lt;BR /&gt;
run;&lt;BR /&gt;
data i1;&lt;BR /&gt;
input Project $ Country $ K1 K2 K3;&lt;BR /&gt;
datalines;&lt;BR /&gt;
B INDIA 1 2 3&lt;BR /&gt;
B US 5 4 7&lt;BR /&gt;
B UK 6 8 9&lt;BR /&gt;
run;&lt;BR /&gt;
%macro a(in=,out=,prefix=);&lt;BR /&gt;
  proc means data=&amp;amp;in noprint;&lt;BR /&gt;
    output out=mean(drop=_:) mean=;&lt;BR /&gt;
    var &amp;amp;prefix:;&lt;BR /&gt;
  run; &lt;BR /&gt;
  data &amp;amp;out;&lt;BR /&gt;
    length Project $20;&lt;BR /&gt;
    set &amp;amp;in mean end=e;&lt;BR /&gt;
    Project=CATX(" ",Project,Country);&lt;BR /&gt;
    if e then Project="All_COUNTRY";&lt;BR /&gt;
    drop Country;&lt;BR /&gt;
    format &amp;amp;prefix: 5.1;&lt;BR /&gt;
  run;&lt;BR /&gt;
%mend a;&lt;BR /&gt;
%a(in=i,out=r,prefix=T)&lt;BR /&gt;
%a(in=i1,out=r1,prefix=K)&lt;BR /&gt;
[/pre]&lt;BR /&gt;
Sincerely,&lt;BR /&gt;
SPR</description>
      <pubDate>Tue, 31 May 2011 14:12:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Mean-Average-Value-for-Dynamic-Variables/m-p/71212#M20538</guid>
      <dc:creator>SPR</dc:creator>
      <dc:date>2011-05-31T14:12:38Z</dc:date>
    </item>
    <item>
      <title>Re: Mean/Average Value for Dynamic Variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Mean-Average-Value-for-Dynamic-Variables/m-p/71213#M20539</link>
      <description>OK.&lt;BR /&gt;
It is easy.&lt;BR /&gt;
[pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
data temp;&lt;BR /&gt;
input Project $ Country $ T1 T2 ;&lt;BR /&gt;
cards;&lt;BR /&gt;
A INDIA 9.5634 8.3234&lt;BR /&gt;
A US 7.4334 6.5434&lt;BR /&gt;
A UK 5.4343 4.5634&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
proc summary data=temp ;&lt;BR /&gt;
 var _numeric_;&lt;BR /&gt;
 output out=all_mean(drop=_type_ _freq_) mean= ;&lt;BR /&gt;
run; &lt;BR /&gt;
&lt;BR /&gt;
proc format ;&lt;BR /&gt;
 picture myfmt&lt;BR /&gt;
    low-high='0009.9'&lt;BR /&gt;
    ;&lt;BR /&gt;
run;&lt;BR /&gt;
data want;&lt;BR /&gt;
 set temp end=last;&lt;BR /&gt;
 format _numeric_ myfmt.;&lt;BR /&gt;
 output;&lt;BR /&gt;
 if last then do;&lt;BR /&gt;
                set all_mean;&lt;BR /&gt;
                country='All_Country';&lt;BR /&gt;
                output;&lt;BR /&gt;
              end;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Wed, 01 Jun 2011 10:42:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Mean-Average-Value-for-Dynamic-Variables/m-p/71213#M20539</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-06-01T10:42:11Z</dc:date>
    </item>
    <item>
      <title>Re: Mean/Average Value for Dynamic Variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Mean-Average-Value-for-Dynamic-Variables/m-p/71214#M20540</link>
      <description>Hi Ksharp,&lt;BR /&gt;
&lt;BR /&gt;
Thanks a lot for your help. Its working as per my requirement.&lt;BR /&gt;
&lt;BR /&gt;
Hi SPR and Cynthia@sas.Thanks for your help.</description>
      <pubDate>Thu, 02 Jun 2011 14:23:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Mean-Average-Value-for-Dynamic-Variables/m-p/71214#M20540</guid>
      <dc:creator>1239</dc:creator>
      <dc:date>2011-06-02T14:23:12Z</dc:date>
    </item>
  </channel>
</rss>

