<?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: Weighting variables in proc tabulate in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Weighting-variables-in-proc-tabulate/m-p/52441#M14423</link>
    <description>Hi. Your proc tabulate is a little complicated.the following code is just an example,you can use proc report to get more about weight variable.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
define estado /group;&lt;BR /&gt;
define ambito /group;&lt;BR /&gt;
define peso /analysis sum;&lt;BR /&gt;
define var1 /analysis mean;&lt;BR /&gt;
define var2 /analysis mean;&lt;BR /&gt;
break after ambito /summarize;&lt;BR /&gt;
compute var1;&lt;BR /&gt;
 s_var1=peso.sum*var1.mean;&lt;BR /&gt;
 if _break_=' ' then sum_var1+s_var1;&lt;BR /&gt;
endcomp;&lt;BR /&gt;
compute var2;&lt;BR /&gt;
 s_var2=peso.sum*var1.mean;&lt;BR /&gt;
 if _break_=' ' then sum_var2+s_var2;&lt;BR /&gt;
endcomp;&lt;BR /&gt;
compute after ambito;&lt;BR /&gt;
 var1.mean=sum_var1/peso.sum;&lt;BR /&gt;
 var2.mean=sum_var2/peso.sum;&lt;BR /&gt;
endcomp;&lt;BR /&gt;
&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
it is Untest.</description>
    <pubDate>Tue, 20 Jul 2010 11:39:46 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2010-07-20T11:39:46Z</dc:date>
    <item>
      <title>Weighting variables in proc tabulate</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Weighting-variables-in-proc-tabulate/m-p/52436#M14418</link>
      <description>Good morning,&lt;BR /&gt;
&lt;BR /&gt;
I want to use the proc tabulate procedure and I want to assing different weights to different variables in the same procedure. If I use the option&lt;BR /&gt;
&lt;BR /&gt;
weight variable_name;&lt;BR /&gt;
&lt;BR /&gt;
at the end of the procedure, all variables of the procedure are weighting by the variable variable_name, but I want only some of them to be weighted.&lt;BR /&gt;
&lt;BR /&gt;
Is it possible? Or I have to do it in several steps.&lt;BR /&gt;
&lt;BR /&gt;
Thank you.</description>
      <pubDate>Mon, 19 Jul 2010 08:23:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Weighting-variables-in-proc-tabulate/m-p/52436#M14418</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-07-19T08:23:10Z</dc:date>
    </item>
    <item>
      <title>Re: Weighting variables in proc tabulate</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Weighting-variables-in-proc-tabulate/m-p/52437#M14419</link>
      <description>Hi . I think you are right. But there is a better choice to use proc report.just need some more codes if you'd like to. And Cynthia@sas.com can do it very well.What you need to do is to post your original code. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Mon, 19 Jul 2010 10:17:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Weighting-variables-in-proc-tabulate/m-p/52437#M14419</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2010-07-19T10:17:41Z</dc:date>
    </item>
    <item>
      <title>Re: Weighting variables in proc tabulate</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Weighting-variables-in-proc-tabulate/m-p/52438#M14420</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
My code is:&lt;BR /&gt;
&lt;BR /&gt;
proc tabulate data=prueba;&lt;BR /&gt;
  var  var1 peso var2 funcion;&lt;BR /&gt;
  class  ambito estado tiempo/ preloadfmt;&lt;BR /&gt;
  table 	all*(n &lt;BR /&gt;
                     funcion*sum &lt;BR /&gt;
                     peso*sum &lt;BR /&gt;
                     var2*mean  &lt;BR /&gt;
	     var1*mean)&lt;BR /&gt;
	ambito=''*(N&lt;BR /&gt;
		peso*sum &lt;BR /&gt;
		var2*mean  &lt;BR /&gt;
		var1*mean),&lt;BR /&gt;
	all estado=''*(all tiempo='')&lt;BR /&gt;
	/ printmiss misstext='-';&lt;BR /&gt;
	weight peso;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
The variables which I want to be weighted are var1 and var2. &lt;BR /&gt;
The variable peso is the variable I want to use for weighting.&lt;BR /&gt;
I do not want to be weighted either peso variable or N variable or funcion variable.&lt;BR /&gt;
&lt;BR /&gt;
But if I write the code as before, all variables are weighted. How can I write it?&lt;BR /&gt;
&lt;BR /&gt;
Thanks</description>
      <pubDate>Mon, 19 Jul 2010 10:49:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Weighting-variables-in-proc-tabulate/m-p/52438#M14420</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-07-19T10:49:35Z</dc:date>
    </item>
    <item>
      <title>Re: Weighting variables in proc tabulate</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Weighting-variables-in-proc-tabulate/m-p/52439#M14421</link>
      <description>Hi:&lt;BR /&gt;
  Since I was a Literature major, I don't dabble in statistics and weights much. However, I do know how to read the documentation.&lt;BR /&gt;
 &lt;BR /&gt;
  A WEIGHT &lt;B&gt;&lt;I&gt;statement&lt;/I&gt;&lt;/B&gt;&lt;I&gt;&lt;/I&gt; will apply to ALL the analysis variables, as described here:&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#/documentation/cdl/en/proc/61895/HTML/default/a002473731.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#/documentation/cdl/en/proc/61895/HTML/default/a002473731.htm&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
  However, PROC TABULATE allows you to have multiple CLASS statements and multiple VAR statements just for the purpose of specifying different &lt;B&gt;&lt;I&gt;options&lt;/I&gt;&lt;/B&gt;&lt;I&gt;&lt;/I&gt; for different category and analysis variables.&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#/documentation/cdl/en/proc/61895/HTML/default/a002473743.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#/documentation/cdl/en/proc/61895/HTML/default/a002473743.htm&lt;/A&gt;&lt;BR /&gt;
 &lt;BR /&gt;
As it says in the documentation on the VAR statement:&lt;BR /&gt;
&lt;B&gt;Tip: Use the WEIGHT option in multiple VAR statements to specify different weights for the analysis variables.  &lt;/B&gt;&lt;BR /&gt;
 &lt;BR /&gt;
The general syntax for having multiple VAR and CLASS statements is:&lt;BR /&gt;
[pre]&lt;BR /&gt;
VAR peso / weight=xxxxx;&lt;BR /&gt;
VAR var1 var2 funcion;&lt;BR /&gt;
CLASS ambito / preloadfmt;&lt;BR /&gt;
CLASS estado tiempo / style={background=pink};&lt;BR /&gt;
[/pre]&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Mon, 19 Jul 2010 13:40:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Weighting-variables-in-proc-tabulate/m-p/52439#M14421</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-07-19T13:40:37Z</dc:date>
    </item>
    <item>
      <title>Re: Weighting variables in proc tabulate</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Weighting-variables-in-proc-tabulate/m-p/52440#M14422</link>
      <description>Ok. Thanks, that was what I wanted.&lt;BR /&gt;
&lt;BR /&gt;
I didn't know how to write multiple VAR statements with differents weights.</description>
      <pubDate>Mon, 19 Jul 2010 14:37:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Weighting-variables-in-proc-tabulate/m-p/52440#M14422</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-07-19T14:37:39Z</dc:date>
    </item>
    <item>
      <title>Re: Weighting variables in proc tabulate</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Weighting-variables-in-proc-tabulate/m-p/52441#M14423</link>
      <description>Hi. Your proc tabulate is a little complicated.the following code is just an example,you can use proc report to get more about weight variable.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
define estado /group;&lt;BR /&gt;
define ambito /group;&lt;BR /&gt;
define peso /analysis sum;&lt;BR /&gt;
define var1 /analysis mean;&lt;BR /&gt;
define var2 /analysis mean;&lt;BR /&gt;
break after ambito /summarize;&lt;BR /&gt;
compute var1;&lt;BR /&gt;
 s_var1=peso.sum*var1.mean;&lt;BR /&gt;
 if _break_=' ' then sum_var1+s_var1;&lt;BR /&gt;
endcomp;&lt;BR /&gt;
compute var2;&lt;BR /&gt;
 s_var2=peso.sum*var1.mean;&lt;BR /&gt;
 if _break_=' ' then sum_var2+s_var2;&lt;BR /&gt;
endcomp;&lt;BR /&gt;
compute after ambito;&lt;BR /&gt;
 var1.mean=sum_var1/peso.sum;&lt;BR /&gt;
 var2.mean=sum_var2/peso.sum;&lt;BR /&gt;
endcomp;&lt;BR /&gt;
&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
it is Untest.</description>
      <pubDate>Tue, 20 Jul 2010 11:39:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Weighting-variables-in-proc-tabulate/m-p/52441#M14423</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2010-07-20T11:39:46Z</dc:date>
    </item>
  </channel>
</rss>

