<?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: group by display in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/group-by-display/m-p/56232#M12008</link>
    <description>Hi:&lt;BR /&gt;
  You will want to investigate the use of the COMPLETEROWS option with PROC REPORT. It can be used by itself, or in conjunction with the PRELOADFMT option and a user-defined format to allow you to control for these data situations:&lt;BR /&gt;
1) you want a 0 row for some combination of group/order variables, especially when the variable appears in the data, but not in your particular combo of group/order variables. For example, you have 4 regions and 3 categories, but not all regions show all 3 categories, even though some regions -do- show all 3 (needs just COMPLETEROWS)&lt;BR /&gt;
and/or&lt;BR /&gt;
2) you want a 0 row to appear for some set of group variables, even if that combination does not appear in the data at all. (needs PRELOADFMT and COMPLETEROWS) (for example, you have 4 regions and 4 categories, but the 4th category is NOT in the data for ANY region and you want a 0 row for that 4th category on the report)&lt;BR /&gt;
 &lt;BR /&gt;
Alternately, you could use a data manipulation technique, such as Scott outlined.&lt;BR /&gt;
&lt;BR /&gt;
As for the other request, I believe you may want the SPANROWS option -- which is a 9.2 option that allows a group or order variable to span multiple rows.&lt;BR /&gt;
&lt;BR /&gt;
BTW, you only use ODS HTML or ODS CSV or ODS TAGSETS.EXCELXP to create a file that Excel can open. It is not technically an "export" to Excel -- only PROC EXPORT or the SAS Libname Engine for Excel create true binary Excel files. All the other ODS methods are creating ASCII text files that Excel can open.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
    <pubDate>Mon, 20 Jul 2009 17:18:42 GMT</pubDate>
    <dc:creator>Cynthia_sas</dc:creator>
    <dc:date>2009-07-20T17:18:42Z</dc:date>
    <item>
      <title>group by display</title>
      <link>https://communities.sas.com/t5/SAS-Programming/group-by-display/m-p/56230#M12006</link>
      <description>I have  5 fields terrid physician city state productgroup total.&lt;BR /&gt;
Productgroup has two categories "competitor" and "mydrug".&lt;BR /&gt;
 I do a group by on all 5 fields in proc report.&lt;BR /&gt;
The issue is, the report shows only the productgroup present for the combination as shown below:&lt;BR /&gt;
for terrid 6789 mydrug is not displayed as it is not presnt for that combination of group by variables.&lt;BR /&gt;
 &lt;BR /&gt;
terrid    physician   city   state     productgroup      total&lt;BR /&gt;
1234     abc_name     pqr    mn        competitor         250&lt;BR /&gt;
1234     abc_name     pqr    mn        mydrug             350&lt;BR /&gt;
6789     def_name     jkl    zx        competitor           150&lt;BR /&gt;
 &lt;BR /&gt;
How to show productgroup  "mydrug" for the last record total as 0 even if its not present. as shown below:&lt;BR /&gt;
terrid    physician   city   state     productgroup      total&lt;BR /&gt;
1234     abc_name     pqr    mn        competitor       250&lt;BR /&gt;
1234     abc_name     pqr    mn        mydrug           350&lt;BR /&gt;
6789     def_name     jkl    zx         competitor         150&lt;BR /&gt;
6789     def_name     jkl    zx         mydug                0&lt;BR /&gt;
&lt;BR /&gt;
And when we export it to excel using ods statement,how to have the product group wraped into single cell instead as two rows?&lt;BR /&gt;
Thanks for your time.</description>
      <pubDate>Mon, 20 Jul 2009 14:39:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/group-by-display/m-p/56230#M12006</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2009-07-20T14:39:41Z</dc:date>
    </item>
    <item>
      <title>Re: group by display</title>
      <link>https://communities.sas.com/t5/SAS-Programming/group-by-display/m-p/56231#M12007</link>
      <description>Appears you have a requirement to list all combinations of  some key variable list - something that can be accomplished by creating a file of all combinations and then MERGE back in that file, setting the TOTAL variable to a zero value, unless the MERGE is contributed from the data file.&lt;BR /&gt;
&lt;BR /&gt;
Have a look at the SAS documentation for the MERGE process and also you have a few options for generating your "all combinations" variable value list -- PROC SQL and PROC SORT NODUPKEY to start. &lt;BR /&gt;
&lt;BR /&gt;
Then for the MERGE, you will want to have a BY statement.  From the SAS support &lt;A href="http://support.sas.com/" target="_blank"&gt;http://support.sas.com/&lt;/A&gt;  website, I used the SEARCH facility and found a few useful technical / conference papers - links are listed below.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
SAS website SAMPLES code - all combinations:&lt;BR /&gt;
&lt;A href="http://ftp.sas.com/techsup/download/sample/samp_lib/basesampEvery_Possible_Merge_Combination.html" target="_blank"&gt;http://ftp.sas.com/techsup/download/sample/samp_lib/basesampEvery_Possible_Merge_Combination.html&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
MERGING vs. JOINING: Comparing the DATA Step with SQL&lt;BR /&gt;
Malachy J. Foley&lt;BR /&gt;
University of North Carolina at Chapel Hill, NC&lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/sugi30/249-30.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi30/249-30.pdf&lt;/A&gt;</description>
      <pubDate>Mon, 20 Jul 2009 15:52:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/group-by-display/m-p/56231#M12007</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-07-20T15:52:02Z</dc:date>
    </item>
    <item>
      <title>Re: group by display</title>
      <link>https://communities.sas.com/t5/SAS-Programming/group-by-display/m-p/56232#M12008</link>
      <description>Hi:&lt;BR /&gt;
  You will want to investigate the use of the COMPLETEROWS option with PROC REPORT. It can be used by itself, or in conjunction with the PRELOADFMT option and a user-defined format to allow you to control for these data situations:&lt;BR /&gt;
1) you want a 0 row for some combination of group/order variables, especially when the variable appears in the data, but not in your particular combo of group/order variables. For example, you have 4 regions and 3 categories, but not all regions show all 3 categories, even though some regions -do- show all 3 (needs just COMPLETEROWS)&lt;BR /&gt;
and/or&lt;BR /&gt;
2) you want a 0 row to appear for some set of group variables, even if that combination does not appear in the data at all. (needs PRELOADFMT and COMPLETEROWS) (for example, you have 4 regions and 4 categories, but the 4th category is NOT in the data for ANY region and you want a 0 row for that 4th category on the report)&lt;BR /&gt;
 &lt;BR /&gt;
Alternately, you could use a data manipulation technique, such as Scott outlined.&lt;BR /&gt;
&lt;BR /&gt;
As for the other request, I believe you may want the SPANROWS option -- which is a 9.2 option that allows a group or order variable to span multiple rows.&lt;BR /&gt;
&lt;BR /&gt;
BTW, you only use ODS HTML or ODS CSV or ODS TAGSETS.EXCELXP to create a file that Excel can open. It is not technically an "export" to Excel -- only PROC EXPORT or the SAS Libname Engine for Excel create true binary Excel files. All the other ODS methods are creating ASCII text files that Excel can open.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Mon, 20 Jul 2009 17:18:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/group-by-display/m-p/56232#M12008</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2009-07-20T17:18:42Z</dc:date>
    </item>
  </channel>
</rss>

