<?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 creates unexpedted missing variables? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-means-creates-unexpedted-missing-variables/m-p/724248#M224841</link>
    <description>&lt;P&gt;By default Proc Means/Summary provides output statistics for every combination of class variable(s).&lt;/P&gt;
&lt;P&gt;So if you have 2 class variables you get a summary for ALL values, _type_ = 0, each of the class variable levels alone, _type_ = 1 and 2, and then the combinations of the two class variables as _type_=3.&lt;/P&gt;
&lt;P&gt;If you only want the last then the option NWAYS on the Proc statement would only have those.&lt;/P&gt;
&lt;P&gt;There are a number of options for selecting which levels appear in the output , a WAYS statement, a TYPES statement, a CLASSDATA&amp;nbsp; date set , COMPLETETYPES and some things that interact with these such as PRELOADFMT.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Believe me, this is a powerful feature. One pass through through the data set to create a bunch of different groups of statistics and then selecting the desired one(s) for a report based on _type_ can be very powerful.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have one recurring project that reports stuff based on statewide, regions, counties, school districts, schools, school type and grades. Generating all of the summaries in one data set allows for very easy, relatively, report tables by selecting type.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 07 Mar 2021 05:59:22 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2021-03-07T05:59:22Z</dc:date>
    <item>
      <title>proc means creates unexpedted missing variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-means-creates-unexpedted-missing-variables/m-p/724242#M224838</link>
      <description>&lt;P&gt;Hi all SAS Users,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a dataset named "&lt;STRONG&gt;_w.trim_amihud&lt;/STRONG&gt;", then I want to have the total annual market capital of all firms in one year in one country, I use the code&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=_w.trim_amihud noprint;
     class LOC year;&lt;BR /&gt;     /*LOC is country*/
	 var ann_mar_cap;&lt;BR /&gt;     /*ann_mar_cap: annual market cap of each firm*/
	 output out=annual_mar_cap sum=sum_ann_mar_cap;&lt;BR /&gt;     /*sum_ann_mar_cap is total market cap of all firms in each year in one country. It is what I want to have*/
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I have two questions:&lt;/P&gt;
&lt;P&gt;1. so whether the code above seems to be reasonable with what I want to have (total annual market capital of all firms in one year in one country)?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. When I run the code, I saw the result as below (&lt;STRONG&gt;annual_mar_cap&lt;/STRONG&gt; dataset)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;LOC	year	_TYPE_	_FREQ_	sum_ann_mar_cap
	.	    0	    9231	1.3262869E14
	1999	1	    3377	4.5681573E13
	2000	1	    3004	4.6454925E13
	2001	1	    2850	4.0492192E13
ARG	.	    2	    36	    71670486162
AUS	.	    2	    305	    615750041684
AUT	.	    2	    71	    32876319884
/*continue with TYPE=2 for all countries*/
ARG	1999	3	    13	    32514376024
ARG	2000	3	    12	    24105289289
ARG	2001	3	    11	    15050820848
AUS	1999	3	    116	    224128296053
AUS	2000	3	    99	    193674631788&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So, it seems to me that there are some missing observations in &lt;STRONG&gt;LOC&lt;/STRONG&gt; or in &lt;STRONG&gt;year&lt;/STRONG&gt;, quite surprise, so, I come back and check directly on the dataset "&lt;STRONG&gt;tri&lt;/STRONG&gt;&lt;SPAN style="font-family: inherit;"&gt;&lt;STRONG&gt;m_amihud&lt;/STRONG&gt;" but it is more surprise that there seems to be no missing observations regarding these two variables.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="My97_0-1615083834022.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/55585i1EF603B83F3497A2/image-size/large?v=v2&amp;amp;px=999" role="button" title="My97_0-1615083834022.png" alt="My97_0-1615083834022.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="My97_1-1615083868540.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/55586i00F2CFDD81B3C314/image-size/large?v=v2&amp;amp;px=999" role="button" title="My97_1-1615083868540.png" alt="My97_1-1615083868540.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;I also put the summary statistic of dataset&amp;nbsp; &lt;STRONG&gt;annual_mar_cap&lt;/STRONG&gt; here;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="My97_2-1615084003869.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/55587i447D51C899774A7F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="My97_2-1615084003869.png" alt="My97_2-1615084003869.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you please help me to sort it out, does the problem relate to _TYPE_ (because I saw the missing obs generated coming from TYPE=0 or 1?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Warmest regards.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 07 Mar 2021 02:29:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-means-creates-unexpedted-missing-variables/m-p/724242#M224838</guid>
      <dc:creator>Phil_NZ</dc:creator>
      <dc:date>2021-03-07T02:29:38Z</dc:date>
    </item>
    <item>
      <title>Re: proc means creates unexpedted missing variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-means-creates-unexpedted-missing-variables/m-p/724243#M224839</link>
      <description>&lt;P&gt;Read about the meaning of the _TYPE_ variable in the documentation.&lt;/P&gt;
&lt;P&gt;Also look at the NWAY option on the PROC MEANS/SUMMARY statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 07 Mar 2021 04:01:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-means-creates-unexpedted-missing-variables/m-p/724243#M224839</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-03-07T04:01:50Z</dc:date>
    </item>
    <item>
      <title>Re: proc means creates unexpedted missing variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-means-creates-unexpedted-missing-variables/m-p/724248#M224841</link>
      <description>&lt;P&gt;By default Proc Means/Summary provides output statistics for every combination of class variable(s).&lt;/P&gt;
&lt;P&gt;So if you have 2 class variables you get a summary for ALL values, _type_ = 0, each of the class variable levels alone, _type_ = 1 and 2, and then the combinations of the two class variables as _type_=3.&lt;/P&gt;
&lt;P&gt;If you only want the last then the option NWAYS on the Proc statement would only have those.&lt;/P&gt;
&lt;P&gt;There are a number of options for selecting which levels appear in the output , a WAYS statement, a TYPES statement, a CLASSDATA&amp;nbsp; date set , COMPLETETYPES and some things that interact with these such as PRELOADFMT.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Believe me, this is a powerful feature. One pass through through the data set to create a bunch of different groups of statistics and then selecting the desired one(s) for a report based on _type_ can be very powerful.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have one recurring project that reports stuff based on statewide, regions, counties, school districts, schools, school type and grades. Generating all of the summaries in one data set allows for very easy, relatively, report tables by selecting type.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 07 Mar 2021 05:59:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-means-creates-unexpedted-missing-variables/m-p/724248#M224841</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-03-07T05:59:22Z</dc:date>
    </item>
  </channel>
</rss>

