<?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: Including all observation categories from a class variable in a proc means in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Including-all-observation-categories-from-a-class-variable-in-a/m-p/868465#M343078</link>
    <description>I would also note that this also worked. Thank you!</description>
    <pubDate>Thu, 06 Apr 2023 15:17:21 GMT</pubDate>
    <dc:creator>G-Scott</dc:creator>
    <dc:date>2023-04-06T15:17:21Z</dc:date>
    <item>
      <title>Including all observation categories from a class variable in a proc means</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Including-all-observation-categories-from-a-class-variable-in-a/m-p/868381#M343033</link>
      <description>Hi All,&lt;BR /&gt;&lt;BR /&gt;So I am using proc means to generate some stats on two variable, let’s say TimeFromEventA and TimeFromEventB for a group of individuals by race/ethnicity.&lt;BR /&gt;&lt;BR /&gt;So, the issue I am running into is I would like lines for all of the class options, even if there are no observations.&lt;BR /&gt;&lt;BR /&gt;For example:&lt;BR /&gt;&lt;BR /&gt;Proc Means data=have;&lt;BR /&gt;Var TimeFromEventA TimeFromEventB;&lt;BR /&gt;Class raceeth;&lt;BR /&gt;Run;&lt;BR /&gt;&lt;BR /&gt;If I don’t have any observations in my data set where raceeth=3…it is not included in the output, and I would like it to be. Any way to make this possible?</description>
      <pubDate>Wed, 05 Apr 2023 23:22:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Including-all-observation-categories-from-a-class-variable-in-a/m-p/868381#M343033</guid>
      <dc:creator>G-Scott</dc:creator>
      <dc:date>2023-04-05T23:22:38Z</dc:date>
    </item>
    <item>
      <title>Re: Including all observation categories from a class variable in a proc means</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Including-all-observation-categories-from-a-class-variable-in-a/m-p/868389#M343036</link>
      <description>&lt;P&gt;So you have to have a method to add values that are not present in the data set.&lt;/P&gt;
&lt;P&gt;One of the ways is to use a FORMAT to provide the values and a PRELOADFMT option and COMPLETETYPES in Proc Means/Summary:&lt;/P&gt;
&lt;P&gt;An example:&lt;/P&gt;
&lt;PRE&gt;Proc format;
value $newgender
'F'='Female'
'M'='Male'
'X'='Other'
;

proc means data=sashelp.class completetypes;
   class sex/preloadfmt;
   format sex $newgender.;
   var height weight;
run;&lt;/PRE&gt;
&lt;P&gt;The format provides a formatted value for a variable expecting values of F, M and X. The SASHELP.CLASS data set has values of F and M for the Sex variable. The Preloadfmt works with Completetypes to accomplish the values that don't appear in the actual data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2023 01:09:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Including-all-observation-categories-from-a-class-variable-in-a/m-p/868389#M343036</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-04-06T01:09:41Z</dc:date>
    </item>
    <item>
      <title>Re: Including all observation categories from a class variable in a proc means</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Including-all-observation-categories-from-a-class-variable-in-a/m-p/868445#M343061</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*
Or try CLASSDATA= option.
*/
data have;
 set sashelp.class;
run;

proc sql;
create table levels as
select distinct sex from have
union
select 'X' from have(obs=1)
union
select 'Y' from have(obs=1)
union
select 'Z' from have(obs=1)
;
quit;

proc means data=have classdata=levels ;
   class sex ;
   var height weight;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Apr 2023 11:49:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Including-all-observation-categories-from-a-class-variable-in-a/m-p/868445#M343061</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-04-06T11:49:21Z</dc:date>
    </item>
    <item>
      <title>Re: Including all observation categories from a class variable in a proc means</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Including-all-observation-categories-from-a-class-variable-in-a/m-p/868446#M343062</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*
Or try CLASSDATA= option.
*/

proc means data=have classdata=levels ;
   class sex ;
   var height weight;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;After all these years of using PROC MEANS/PROC SUMMARY on a daily basis at work, and trying to explain PROC MEANS/PROC SUMMARY to total strangers while I am on vacation, I still learn something new from this forum. Thanks,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2023 11:59:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Including-all-observation-categories-from-a-class-variable-in-a/m-p/868446#M343062</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-04-06T11:59:10Z</dc:date>
    </item>
    <item>
      <title>Re: Including all observation categories from a class variable in a proc means</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Including-all-observation-categories-from-a-class-variable-in-a/m-p/868465#M343078</link>
      <description>I would also note that this also worked. Thank you!</description>
      <pubDate>Thu, 06 Apr 2023 15:17:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Including-all-observation-categories-from-a-class-variable-in-a/m-p/868465#M343078</guid>
      <dc:creator>G-Scott</dc:creator>
      <dc:date>2023-04-06T15:17:21Z</dc:date>
    </item>
  </channel>
</rss>

