<?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: Imputing missing values to 0 when grouping variable not present in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Imputing-missing-values-to-0-when-grouping-variable-not-present/m-p/779608#M248331</link>
    <description>&lt;P&gt;Oddly, it looks like the order and type of the variables is impacting things. If I change my proc report to this:&lt;/P&gt;
&lt;PRE&gt;proc report data=summary completerows;
	column Name Type (ID Count);
	define Name / group;
	DEFINE Type / group preloadfmt format=$type. exclusive;
	define ID / 'ID' ;
	define Count / 'Count';
run;&lt;/PRE&gt;
&lt;P&gt;it works fine. Unfortunately, this won't work with my actual data--if I define ID as character, it goes right back to being broken, and in my real dataset, it's a character variable due to leading 0s. It also, of course, starts using it in break / summarize sections, which isn't ideal...&lt;/P&gt;</description>
    <pubDate>Wed, 10 Nov 2021 17:33:07 GMT</pubDate>
    <dc:creator>scify</dc:creator>
    <dc:date>2021-11-10T17:33:07Z</dc:date>
    <item>
      <title>Imputing missing values to 0 when grouping variable not present</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Imputing-missing-values-to-0-when-grouping-variable-not-present/m-p/779445#M248234</link>
      <description>&lt;P&gt;This feels like a simple question, but I haven't been able to find the answer anywhere (I'm probably just not wording it properly). Say I have the following data&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;ID         Type
1          A
1          A
1          B
1          A
2          A
2          A
3          B
3          B&lt;/PRE&gt;
&lt;P&gt;And I've summarized it for PROC Report in the following way:&lt;/P&gt;
&lt;PRE&gt;ID         Type    Count
1          A          3
1          B          1
2          A          2
3          B          2&lt;/PRE&gt;
&lt;P&gt;Is there a way, either during the summarizing or the PROC, to have SAS impute the missing values of Type and set Count to 0? I.E.&lt;/P&gt;
&lt;PRE&gt;ID         Type    Count
1          A          3
1          B          1
2          A          2
2          B          0
3          A          0
3          B          2&lt;/PRE&gt;
&lt;P&gt;I know Type will always be either A or B, but not all IDs will have at least one instance of both, and for consistency in the PROC Report, I'd like to always have both rows.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Nov 2021 21:47:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Imputing-missing-values-to-0-when-grouping-variable-not-present/m-p/779445#M248234</guid>
      <dc:creator>scify</dc:creator>
      <dc:date>2021-11-09T21:47:00Z</dc:date>
    </item>
    <item>
      <title>Re: Imputing missing values to 0 when grouping variable not present</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Imputing-missing-values-to-0-when-grouping-variable-not-present/m-p/779447#M248236</link>
      <description>If you have all the values, look at the COMPLETEROWS option on PROC REPORT?&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/n1dz7jdasx5t56n1rmlx346dyk6n.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/n1dz7jdasx5t56n1rmlx346dyk6n.htm&lt;/A&gt;</description>
      <pubDate>Tue, 09 Nov 2021 22:00:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Imputing-missing-values-to-0-when-grouping-variable-not-present/m-p/779447#M248236</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-11-09T22:00:51Z</dc:date>
    </item>
    <item>
      <title>Re: Imputing missing values to 0 when grouping variable not present</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Imputing-missing-values-to-0-when-grouping-variable-not-present/m-p/779507#M248268</link>
      <description>&lt;P&gt;You have to change the code summarising the data:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.Original;
   input ID Type $;
   datalines;
1          A
1          A
1          B
1          A
2          A
2          A
3          B
3          B
;

proc summary data=work.Original nway completetypes;
   class ID Type;
   output out= work.Counted(drop= _type_ rename=(_freq_ = count));
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 10 Nov 2021 06:46:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Imputing-missing-values-to-0-when-grouping-variable-not-present/m-p/779507#M248268</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-11-10T06:46:11Z</dc:date>
    </item>
    <item>
      <title>Re: Imputing missing values to 0 when grouping variable not present</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Imputing-missing-values-to-0-when-grouping-variable-not-present/m-p/779543#M248292</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.Original;
   input ID Type $;
   datalines;
1          A
1          A
1          B
1          A
2          A
2          A
3          B
3          B
;
proc freq data=Original;
table id*type/list sparse nocum nopercent;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 10 Nov 2021 11:51:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Imputing-missing-values-to-0-when-grouping-variable-not-present/m-p/779543#M248292</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-11-10T11:51:06Z</dc:date>
    </item>
    <item>
      <title>Re: Imputing missing values to 0 when grouping variable not present</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Imputing-missing-values-to-0-when-grouping-variable-not-present/m-p/779584#M248314</link>
      <description>&lt;P&gt;Something like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
  input ID Type $ @@;
cards;
1 A 1 A
1 B 1 A
2 A 2 A
3 B 3 B
;

proc format ;
  value $types 'A'='A' 'B'='B';
run;

proc report data=have completerows;
  column id type n ;
  define id / group ;
  define type / group format=$types. PRELOADFMT ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 10 Nov 2021 15:46:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Imputing-missing-values-to-0-when-grouping-variable-not-present/m-p/779584#M248314</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-11-10T15:46:55Z</dc:date>
    </item>
    <item>
      <title>Re: Imputing missing values to 0 when grouping variable not present</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Imputing-missing-values-to-0-when-grouping-variable-not-present/m-p/779587#M248316</link>
      <description>&lt;P&gt;That's definitely a start! It works for the simple example I posted above, but if I try to add another grouping column (say, Name,which has a one-to-one match with ID), it breaks rather spectacularly. Do you know if there's a way to make it work with three variables (ID, Name, and Type) instead of two?&lt;/P&gt;</description>
      <pubDate>Wed, 10 Nov 2021 15:59:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Imputing-missing-values-to-0-when-grouping-variable-not-present/m-p/779587#M248316</guid>
      <dc:creator>scify</dc:creator>
      <dc:date>2021-11-10T15:59:35Z</dc:date>
    </item>
    <item>
      <title>Re: Imputing missing values to 0 when grouping variable not present</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Imputing-missing-values-to-0-when-grouping-variable-not-present/m-p/779591#M248318</link>
      <description>&lt;P&gt;Pretty much. I mentioned this above in my response to Reeza, but the issue I'm hitting now is that I've been asked to add another column (Name) which has a 1-to-1 match with ID, but is causing the Proc Report to go a little crazy in the output. Do you know if there's a way to handle that, other than dumping the entirety of Name into its own format and using preloadfmt there as well?&lt;/P&gt;</description>
      <pubDate>Wed, 10 Nov 2021 16:12:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Imputing-missing-values-to-0-when-grouping-variable-not-present/m-p/779591#M248318</guid>
      <dc:creator>scify</dc:creator>
      <dc:date>2021-11-10T16:12:02Z</dc:date>
    </item>
    <item>
      <title>Re: Imputing missing values to 0 when grouping variable not present</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Imputing-missing-values-to-0-when-grouping-variable-not-present/m-p/779601#M248326</link>
      <description>If the data combination doesn't exist in the raw data you have to tell SAS somehow that it does exist and a format or classdata does that. &lt;BR /&gt;Or you pre-process the data, which may still require a format, classdata or SQL logic to mimic the functionality. &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 10 Nov 2021 16:39:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Imputing-missing-values-to-0-when-grouping-variable-not-present/m-p/779601#M248326</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-11-10T16:39:03Z</dc:date>
    </item>
    <item>
      <title>Re: Imputing missing values to 0 when grouping variable not present</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Imputing-missing-values-to-0-when-grouping-variable-not-present/m-p/779602#M248327</link>
      <description>&lt;PRE&gt;data original;
	input ID Name $ Type $;
	datalines;
1   Timmy     A
1   Timmy     A
1   Timmy     B
1   Timmy     A
2   Sarah     B
2   Sarah     B
3   John      A
3   John      A
;

proc sql;
	create table summary as
	select ID, Name, Type, count(*) as Count from original
	group by 1,2,3;
quit;

proc format;
	value $type 'A'='A' 'B'='B';

proc report data=summary completerows;
	column ID Name Type (Count);
	define ID / group  ;
	define Name / group;
	DEFINE Type / preloadfmt format=$type. exclusive;
	define Count / display;
run;&lt;/PRE&gt;
&lt;P&gt;The above gives me this as the output:&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="25%" height="30px"&gt;ID&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;Name&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;Type&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;Count&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="30px"&gt;1&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;John&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;Sarah&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD height="30px"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD height="30px"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD height="30px"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD height="30px"&gt;Timmy&lt;/TD&gt;
&lt;TD height="30px"&gt;A&lt;/TD&gt;
&lt;TD height="30px"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD height="30px"&gt;B&lt;/TD&gt;
&lt;TD height="30px"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD height="30px"&gt;2&lt;/TD&gt;
&lt;TD height="30px"&gt;John&lt;/TD&gt;
&lt;TD height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD height="30px"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD height="30px"&gt;... etc&lt;/TD&gt;
&lt;TD height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit: And fixing my mistake of not labeling the Type column as a group variable produces this:&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="25%"&gt;ID&lt;/TD&gt;
&lt;TD width="25%"&gt;Name&lt;/TD&gt;
&lt;TD width="25%"&gt;Type&lt;/TD&gt;
&lt;TD width="25%"&gt;Count&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%"&gt;1&lt;/TD&gt;
&lt;TD width="25%"&gt;John&lt;/TD&gt;
&lt;TD width="25%"&gt;A&lt;/TD&gt;
&lt;TD width="25%"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="25%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="25%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="25%"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="25%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="25%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="25%"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="25%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="25%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="25%"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="25%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="25%"&gt;B&lt;/TD&gt;
&lt;TD width="25%"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="25%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="25%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="25%"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="25%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="25%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="25%"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="25%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="25%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="25%"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="25%"&gt;Sarah&lt;/TD&gt;
&lt;TD width="25%"&gt;A&lt;/TD&gt;
&lt;TD width="25%"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;etc...&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Nov 2021 16:55:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Imputing-missing-values-to-0-when-grouping-variable-not-present/m-p/779602#M248327</guid>
      <dc:creator>scify</dc:creator>
      <dc:date>2021-11-10T16:55:41Z</dc:date>
    </item>
    <item>
      <title>Re: Imputing missing values to 0 when grouping variable not present</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Imputing-missing-values-to-0-when-grouping-variable-not-present/m-p/779604#M248329</link>
      <description>&lt;P&gt;Yes, because COMPLETEROWS will essentially create a cartesian product between all your group variables . Which likely means you have missing TYPE somewhere in your data. If you cannot use the COMPLETEROWS option you have to use either CLASSDATA or PRELOADFMT ahead of time to structure your data for proc report. Or if you don't have ID as a group variable, as a display variable that would also work but then it would repeat.&lt;BR /&gt;&lt;BR /&gt;PROC TABULATE with PRELOADFMT will probably give you what you need.&lt;BR /&gt;&lt;BR /&gt;COMPLETEROWS&lt;BR /&gt;creates all possible combinations of the group variable values.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Nov 2021 17:04:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Imputing-missing-values-to-0-when-grouping-variable-not-present/m-p/779604#M248329</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-11-10T17:04:03Z</dc:date>
    </item>
    <item>
      <title>Re: Imputing missing values to 0 when grouping variable not present</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Imputing-missing-values-to-0-when-grouping-variable-not-present/m-p/779608#M248331</link>
      <description>&lt;P&gt;Oddly, it looks like the order and type of the variables is impacting things. If I change my proc report to this:&lt;/P&gt;
&lt;PRE&gt;proc report data=summary completerows;
	column Name Type (ID Count);
	define Name / group;
	DEFINE Type / group preloadfmt format=$type. exclusive;
	define ID / 'ID' ;
	define Count / 'Count';
run;&lt;/PRE&gt;
&lt;P&gt;it works fine. Unfortunately, this won't work with my actual data--if I define ID as character, it goes right back to being broken, and in my real dataset, it's a character variable due to leading 0s. It also, of course, starts using it in break / summarize sections, which isn't ideal...&lt;/P&gt;</description>
      <pubDate>Wed, 10 Nov 2021 17:33:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Imputing-missing-values-to-0-when-grouping-variable-not-present/m-p/779608#M248331</guid>
      <dc:creator>scify</dc:creator>
      <dc:date>2021-11-10T17:33:07Z</dc:date>
    </item>
    <item>
      <title>Re: Imputing missing values to 0 when grouping variable not present</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Imputing-missing-values-to-0-when-grouping-variable-not-present/m-p/779610#M248332</link>
      <description>Try removing COMPLETEROWS if you're using PRELOADFMT, both are not necessary.</description>
      <pubDate>Wed, 10 Nov 2021 17:50:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Imputing-missing-values-to-0-when-grouping-variable-not-present/m-p/779610#M248332</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-11-10T17:50:30Z</dc:date>
    </item>
    <item>
      <title>Re: Imputing missing values to 0 when grouping variable not present</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Imputing-missing-values-to-0-when-grouping-variable-not-present/m-p/779613#M248335</link>
      <description>&lt;P&gt;Removing COMPLETEROWS takes it back to the initial issue: it only displays the values of TYPE that exist for each ID/Name row, instead of having both.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Nov 2021 17:55:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Imputing-missing-values-to-0-when-grouping-variable-not-present/m-p/779613#M248335</guid>
      <dc:creator>scify</dc:creator>
      <dc:date>2021-11-10T17:55:37Z</dc:date>
    </item>
    <item>
      <title>Re: Imputing missing values to 0 when grouping variable not present</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Imputing-missing-values-to-0-when-grouping-variable-not-present/m-p/779614#M248336</link>
      <description>&lt;P&gt;You will generally have more control if you just write a program to do the counting and just use PROC REPORT or other tools to make the presentation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So for this example where there is one variable with a fixed set of values that might not all be present you can first get the summary of values that are.&amp;nbsp; This will also produce the set of values for the other grouping variables that want to use as the basis for adding in the empty cells.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=have nway ;
  class id name type ;
  output out=step1 ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So in this case we will get all of the ID*NAME combinations but some of them will only have some of the levels of TYPE.&amp;nbsp; So let's use that to build a dataset that has all of the possible levels for TYPE for all of the those combinations of ID and NAME and just set the count to zero.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data step2;
  set step1;
  by id name;
  if first.name;
  _freq_=0;
  do type='A','B';
     output;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now we can combine the two and get the full dataset. The counts that actually existed will overwrite the zeros we generated in STEP2.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data report;
   merge step2 step1;
   by id name type;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now we can make our report.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc print data=report label;
  var id name type _freq_;
  label _freq_='Count';
run;
  &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 10 Nov 2021 18:02:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Imputing-missing-values-to-0-when-grouping-variable-not-present/m-p/779614#M248336</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-11-10T18:02:05Z</dc:date>
    </item>
    <item>
      <title>Re: Imputing missing values to 0 when grouping variable not present</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Imputing-missing-values-to-0-when-grouping-variable-not-present/m-p/779621#M248340</link>
      <description>Thank you! I didn't know you could split rows out like that in a data step; this produced exactly what I was looking for.</description>
      <pubDate>Wed, 10 Nov 2021 18:24:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Imputing-missing-values-to-0-when-grouping-variable-not-present/m-p/779621#M248340</guid>
      <dc:creator>scify</dc:creator>
      <dc:date>2021-11-10T18:24:57Z</dc:date>
    </item>
    <item>
      <title>Re: Imputing missing values to 0 when grouping variable not present</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Imputing-missing-values-to-0-when-grouping-variable-not-present/m-p/779622#M248341</link>
      <description>Show what you want from your Original data set please.</description>
      <pubDate>Wed, 10 Nov 2021 18:27:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Imputing-missing-values-to-0-when-grouping-variable-not-present/m-p/779622#M248341</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-11-10T18:27:32Z</dc:date>
    </item>
  </channel>
</rss>

