<?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: Summary output with all where variables in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Summary-output-with-all-where-variables/m-p/74517#M21636</link>
    <description>I'm not sure I understand what you are looking for.  The following is based on the understanding that the data desribes the years and channels, but a where statement is the only thing that describes the desired 'types' you want to include.&lt;BR /&gt;
&lt;BR /&gt;
If that is correct, then I'd suggest including the where statement as a macro variable and using it to build a file that contains all of the possible permutations.&lt;BR /&gt;
&lt;BR /&gt;
For example:&lt;BR /&gt;
&lt;BR /&gt;
proc format;&lt;BR /&gt;
  value $ channellbl&lt;BR /&gt;
    'A'='First'&lt;BR /&gt;
    'B'='Second'&lt;BR /&gt;
    'C'='Third';&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data loan_all;&lt;BR /&gt;
  input year (channel type) ($1.) numloans;&lt;BR /&gt;
  cards;&lt;BR /&gt;
1 A1 100&lt;BR /&gt;
2 B1 5&lt;BR /&gt;
3 C1 23&lt;BR /&gt;
4 A2 7&lt;BR /&gt;
5 B2 10&lt;BR /&gt;
;&lt;BR /&gt;
&lt;BR /&gt;
%let where='1','2','3';&lt;BR /&gt;
&lt;BR /&gt;
proc sort data=loan_all (keep=year) nodupkey out=allcombos1;&lt;BR /&gt;
  by year;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc sort data=loan_all (keep=channel) nodupkey out=allcombos2;&lt;BR /&gt;
  by channel;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data allcombos3 (drop=_:);&lt;BR /&gt;
  length type $1;&lt;BR /&gt;
  _want=compress("&amp;amp;where.","'");&lt;BR /&gt;
  _i=1;&lt;BR /&gt;
  do while (scan(_want,_i) NE "");&lt;BR /&gt;
    type=put(scan(_want,_i),$1.);&lt;BR /&gt;
    _i+1;&lt;BR /&gt;
    output;&lt;BR /&gt;
  end;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
     create table selectlevels as&lt;BR /&gt;
     select *&lt;BR /&gt;
     from   Allcombos1,Allcombos2,Allcombos3&lt;BR /&gt;
;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
proc summary data=loan_all completetypes missing nway&lt;BR /&gt;
             classdata=selectlevels;&lt;BR /&gt;
  class year channel type;&lt;BR /&gt;
&lt;BR /&gt;
  var numloans;&lt;BR /&gt;
  output out=test sum=;&lt;BR /&gt;
  format channel $channellbl.;&lt;BR /&gt;
  where type in (&amp;amp;where.);&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data test;&lt;BR /&gt;
  set test;&lt;BR /&gt;
  if missing(numloans) the numloans=0;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc print data=test;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
The code, of course, could be reconfigured to be a SAS macro, in itself, but I didn't think it was worth the effort until we find out that it is close to what you were seeking.&lt;BR /&gt;
&lt;BR /&gt;
Art</description>
    <pubDate>Sat, 25 Sep 2010 02:33:50 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2010-09-25T02:33:50Z</dc:date>
    <item>
      <title>Summary output with all where variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Summary-output-with-all-where-variables/m-p/74514#M21633</link>
      <description>Is it possible to force proc summary to include all possible combinations of variables in the where statement, even when those combinations don't appear in the dataset?  I know that you can do this for the class statement.  Maybe in conjunction with proc report?&lt;BR /&gt;
&lt;BR /&gt;
Thanks!</description>
      <pubDate>Fri, 24 Sep 2010 17:44:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Summary-output-with-all-where-variables/m-p/74514#M21633</guid>
      <dc:creator>brp4h</dc:creator>
      <dc:date>2010-09-24T17:44:52Z</dc:date>
    </item>
    <item>
      <title>Re: Summary output with all where variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Summary-output-with-all-where-variables/m-p/74515#M21634</link>
      <description>Consider sharing sample INPUT and (desired) OUTPUT data represented - consider the WHERE statement is an input filter and the WHERE= (the dataset option) is an output-side filter.  You're asking that combinations not meeting the WHERE statement filter criteria be included in the SUMMARY execution output -- plz help to explain this opportunity with your data-sample as an example of what you want to see.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Fri, 24 Sep 2010 19:13:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Summary-output-with-all-where-variables/m-p/74515#M21634</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-09-24T19:13:19Z</dc:date>
    </item>
    <item>
      <title>Re: Summary output with all where variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Summary-output-with-all-where-variables/m-p/74516#M21635</link>
      <description>Hi, Scott, &lt;BR /&gt;
&lt;BR /&gt;
Here is an example:&lt;BR /&gt;
&lt;BR /&gt;
year channel type numloans&lt;BR /&gt;
1 A 1 100&lt;BR /&gt;
2 B 1 5&lt;BR /&gt;
3 C 1 23&lt;BR /&gt;
4 A 2 7&lt;BR /&gt;
5 B 2 10&lt;BR /&gt;
&lt;BR /&gt;
proc summary data=loan_all missing completetypes;&lt;BR /&gt;
   class year channel /preloadfmt exclusive;&lt;BR /&gt;
   var numloans;&lt;BR /&gt;
   output out=test sum=;&lt;BR /&gt;
   format channel $channellbl.;&lt;BR /&gt;
   where type in ('1','2','3');&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
My output will have every permutation of year and channel for types 1 and 2, but not for 3 because type is not in the class statement and never appears in the data.  How can I print 0 for numloans for every permutation of year and channel for type 3?  I cannot create a temporary dataset with all 0s because the variables will change each time the program is run.</description>
      <pubDate>Fri, 24 Sep 2010 19:21:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Summary-output-with-all-where-variables/m-p/74516#M21635</guid>
      <dc:creator>brp4h</dc:creator>
      <dc:date>2010-09-24T19:21:09Z</dc:date>
    </item>
    <item>
      <title>Re: Summary output with all where variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Summary-output-with-all-where-variables/m-p/74517#M21636</link>
      <description>I'm not sure I understand what you are looking for.  The following is based on the understanding that the data desribes the years and channels, but a where statement is the only thing that describes the desired 'types' you want to include.&lt;BR /&gt;
&lt;BR /&gt;
If that is correct, then I'd suggest including the where statement as a macro variable and using it to build a file that contains all of the possible permutations.&lt;BR /&gt;
&lt;BR /&gt;
For example:&lt;BR /&gt;
&lt;BR /&gt;
proc format;&lt;BR /&gt;
  value $ channellbl&lt;BR /&gt;
    'A'='First'&lt;BR /&gt;
    'B'='Second'&lt;BR /&gt;
    'C'='Third';&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data loan_all;&lt;BR /&gt;
  input year (channel type) ($1.) numloans;&lt;BR /&gt;
  cards;&lt;BR /&gt;
1 A1 100&lt;BR /&gt;
2 B1 5&lt;BR /&gt;
3 C1 23&lt;BR /&gt;
4 A2 7&lt;BR /&gt;
5 B2 10&lt;BR /&gt;
;&lt;BR /&gt;
&lt;BR /&gt;
%let where='1','2','3';&lt;BR /&gt;
&lt;BR /&gt;
proc sort data=loan_all (keep=year) nodupkey out=allcombos1;&lt;BR /&gt;
  by year;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc sort data=loan_all (keep=channel) nodupkey out=allcombos2;&lt;BR /&gt;
  by channel;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data allcombos3 (drop=_:);&lt;BR /&gt;
  length type $1;&lt;BR /&gt;
  _want=compress("&amp;amp;where.","'");&lt;BR /&gt;
  _i=1;&lt;BR /&gt;
  do while (scan(_want,_i) NE "");&lt;BR /&gt;
    type=put(scan(_want,_i),$1.);&lt;BR /&gt;
    _i+1;&lt;BR /&gt;
    output;&lt;BR /&gt;
  end;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
     create table selectlevels as&lt;BR /&gt;
     select *&lt;BR /&gt;
     from   Allcombos1,Allcombos2,Allcombos3&lt;BR /&gt;
;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
proc summary data=loan_all completetypes missing nway&lt;BR /&gt;
             classdata=selectlevels;&lt;BR /&gt;
  class year channel type;&lt;BR /&gt;
&lt;BR /&gt;
  var numloans;&lt;BR /&gt;
  output out=test sum=;&lt;BR /&gt;
  format channel $channellbl.;&lt;BR /&gt;
  where type in (&amp;amp;where.);&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data test;&lt;BR /&gt;
  set test;&lt;BR /&gt;
  if missing(numloans) the numloans=0;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc print data=test;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
The code, of course, could be reconfigured to be a SAS macro, in itself, but I didn't think it was worth the effort until we find out that it is close to what you were seeking.&lt;BR /&gt;
&lt;BR /&gt;
Art</description>
      <pubDate>Sat, 25 Sep 2010 02:33:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Summary-output-with-all-where-variables/m-p/74517#M21636</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2010-09-25T02:33:50Z</dc:date>
    </item>
  </channel>
</rss>

