<?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 and subgroups coding in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Group-and-subgroups-coding/m-p/274248#M54698</link>
    <description>&lt;P&gt;You didn't give us some data to test yet ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc report data=sashelp.class nowd ;
columns sex age new_age pctn;
define sex/group noprint;
define age/group noprint;
define new_age/computed style={asis=on};
define pctn/format=percent8.2;
compute new_age/character length=20;
 new_age=cats('09'x,put(age,best8.));
endcomp;
compute before sex;
 new_age=sex;
endcomp;
break before sex/summarize;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/3414i09DCABB9ADAD24D7/image-size/original?v=v2&amp;amp;px=-1" border="0" alt="x.png" title="x.png" /&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 01 Jun 2016 01:19:43 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2016-06-01T01:19:43Z</dc:date>
    <item>
      <title>Group and subgroups coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Group-and-subgroups-coding/m-p/274187#M54679</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to write a code whose output&amp;nbsp;has the follwing format:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Group1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Count&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Subgroup1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Count&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Subgroup2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Count&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Group2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Count&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Subgroup3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Count&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Subgroup4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Count&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %&lt;/P&gt;&lt;P&gt;where subgroups are essentially a part of the groups.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there an easy way to do this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Neha.&lt;/P&gt;</description>
      <pubDate>Tue, 31 May 2016 19:44:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Group-and-subgroups-coding/m-p/274187#M54679</guid>
      <dc:creator>analyst_work</dc:creator>
      <dc:date>2016-05-31T19:44:35Z</dc:date>
    </item>
    <item>
      <title>Re: Group and subgroups coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Group-and-subgroups-coding/m-p/274194#M54682</link>
      <description>&lt;P&gt;Some applications support what is referred to as a MULTILABEL format to do such things. Only a few procedures such as Means, Summary and Tabulate support them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here are some examples with proc tabulate. Note that different options and how the format is defined affect the output.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* To demonstrate that the order of definition affects appearance in
   multilabel formats. Also appearance options to show the spaces to
   get the indent as desired and fix column widths.
   And investigate whether class level format based style overrides work
with MLF in proc tabulate.  Result: NO.
*/
proc format library=work;
value accidentl (multilabel notsorted)
1-5 = 'Accidents'
1-3 = ' Transport accidents'
1 = '   Motor vehicle accidents'
2 = '   Water, air, and space'
3 = '   Other land transport accidents'
4-5 = ' Nontransport accidents'
5 = '   Fishing'
;
value accidentr (multilabel notsorted)
1-5 = 'Accidents'
1-3 = ' Transport accidents'
4-5 = ' Nontransport accidents'
1 = '   Motor vehicle accidents'
2 = '   Water, air, and space'
3 = '   Other land transport accidents'
5 = '   Fishing'
;
value accidents (multilabel notsorted)
1 = '   Motor vehicle accidents'
2 = '   Water, air, and space'
3 = '   Other land transport accidents'
5 = '   Fishing'
1-5 = 'Accidents'
1-3 = ' Transport accidents'
4-5 = ' Nontransport accidents'
;
value mf
1 = "Male"
2 = "Female"
;
value mycolor
1='white'
2='red'
3='green'
4='blue'
5='orange'
6='purple'
;
value accsimple
1 = 'Motor vehicle accidents'
2 = 'Water, air, and space'
3 = 'Other land transport accidents'
4 = 'Nontransport accidents'
5 = 'Fishing'
;
value MyColorl (multilabel notsorted)
1-5 = 'white'
1-3 = 'red'
1 = 'blue'
2 = 'orange'
3 = 'pink'
4-5 = 'purple'
5 = 'black'
;
run;

/* populate a dataset to display */
/* This specifically does NOT generate any data for FISHING above*/
/* to display the behavior of the options below in those cases. */
data junk; 
do i=1 to 50;
type = round(4*ranuni(1234)+.5);
sex = round(2*ranuni(3455)+.5);
output;
end; 
run;


/* Notice that before we get here the data is NOT sorted */
/* in any manner!!!! */
title 'Option Order=Data Preloadfmt Printmiss Misstext=0 format accidentl';
proc tabulate data=junk order=data ;
   class type / mlf PRELOADFMT;
   /*ASIS preserves the leading spaces in the format, Cellwidth here is optional
     for this demo. These will ONLY affect ODS output such as HTML, RTF or PDF
     not the OUTPUT window
  */
   classlev type/ style=[asis=on cellwidth=1.5in];
   class sex;
   /* the formatted values of SEX normally take up different lengths, this fixes
      the column widths to be the same for both headers. May cause interesting
      appearances with large numbers of displayed digits if requested in formats*/
   classlev sex/ style=[cellwidth=.5in];
   /* to get the ALL to have the same width as SEX need to specify this way*/
   table type=' ', all='Total'*{style=[cellwidth=.5in]}*n=' '*f=comma9. sex=' '*n=' '*f=comma8.
   / printmiss misstext='0';
   format type accidentl. sex mf.;
run;title;

title 'Option simple format and classlev background color';
proc tabulate data=junk order=data ;
   class type / ;
   /*ASIS preserves the leading spaces in the format, Cellwidth here is optional
     for this demo. These will ONLY affect ODS output such as HTML, RTF or PDF
     not the OUTPUT window
  */
   classlev type/ style=[asis=on cellwidth=1.5in background=mycolor.];
   class sex;
   /* the formatted values of SEX normally take up different lengths, this fixes
      the column widths to be the same for both headers. May cause interesting
      appearances with large numbers of displayed digits if requested in formats*/
   classlev sex/ style=[cellwidth=.5in];
   /* to get the ALL to have the same width as SEX need to specify this way*/
   table type=' ', all='Total'*{style=[cellwidth=.5in]}*n=' '*f=comma9. sex=' '*n=' '*f=comma8.
   / row=float misstext='0';
   format type accsimple. sex mf.;
run;title;

title 'Option Order=Data Preloadfmt Printmiss Misstext=0 format accidentl classlev background';
proc tabulate data=junk order=data;
   class type / mlf PRELOADFMT;
   classlev type/ style=[asis=on cellwidth=1.5in background=mycolor.];
   class sex;
   classlev sex/ style=[cellwidth=.5in];
   table type=' ', all='Total'*{style=[cellwidth=.5in]}*n=' '*f=comma9. sex=' '*n=' '*f=comma8.
   / printmiss misstext='0';
   format type accidentl. sex mf.;
run;title;
title 'Option Order=Data Preloadfmt Printmiss Misstext=0 format accidents';
proc tabulate data=junk order=data;
   class type / mlf PRELOADFMT;
   classlev type/ style=[asis=on cellwidth=1.5in];
   class sex;
   classlev sex/ style=[cellwidth=.5in];
   table type=' ', all='Total'*{style=[cellwidth=.5in]}*n=' '*f=comma9. sex=' '*n=' '*f=comma8.
   / printmiss misstext='0';
   format type accidents. sex mf.;
run;title;
 

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 31 May 2016 20:13:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Group-and-subgroups-coding/m-p/274194#M54682</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-05-31T20:13:08Z</dc:date>
    </item>
    <item>
      <title>Re: Group and subgroups coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Group-and-subgroups-coding/m-p/274248#M54698</link>
      <description>&lt;P&gt;You didn't give us some data to test yet ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc report data=sashelp.class nowd ;
columns sex age new_age pctn;
define sex/group noprint;
define age/group noprint;
define new_age/computed style={asis=on};
define pctn/format=percent8.2;
compute new_age/character length=20;
 new_age=cats('09'x,put(age,best8.));
endcomp;
compute before sex;
 new_age=sex;
endcomp;
break before sex/summarize;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/3414i09DCABB9ADAD24D7/image-size/original?v=v2&amp;amp;px=-1" border="0" alt="x.png" title="x.png" /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jun 2016 01:19:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Group-and-subgroups-coding/m-p/274248#M54698</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-06-01T01:19:43Z</dc:date>
    </item>
    <item>
      <title>Re: Group and subgroups coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Group-and-subgroups-coding/m-p/274273#M54702</link>
      <description>&lt;P&gt;Like this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc tabulate data=SASHELP.CLASS;
  class SEX AGE;
  table SEX *(all AGE=' '),pctn;
run;&lt;/CODE&gt;&lt;/PRE&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;DIV class="branch"&gt;&lt;BR /&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" rules="all" frame="box" cellspacing="0" cellpadding="5" summary="Procedure Tabulate: Table 1"&gt;&lt;COLGROUP&gt; &lt;COL /&gt; &lt;COL /&gt;&lt;/COLGROUP&gt; &lt;COLGROUP&gt; &lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="c m header" colspan="2" scope="colgroup"&gt;&amp;nbsp;&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;PctN&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="l t rowheader" scope="row"&gt;Sex&lt;/TH&gt;
&lt;TH class="l t rowheader" scope="row"&gt;&amp;nbsp;&lt;/TH&gt;
&lt;TD class="r b data" rowspan="2"&gt;47.37&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l t rowheader" rowspan="6" scope="rowgroup"&gt;F&lt;/TH&gt;
&lt;TH class="l t rowheader" scope="row"&gt;All&lt;/TH&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l t rowheader" scope="row"&gt;11&lt;/TH&gt;
&lt;TD class="r b data"&gt;5.26&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l t rowheader" scope="row"&gt;12&lt;/TH&gt;
&lt;TD class="r b data"&gt;10.53&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l t rowheader" scope="row"&gt;13&lt;/TH&gt;
&lt;TD class="r b data"&gt;10.53&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l t rowheader" scope="row"&gt;14&lt;/TH&gt;
&lt;TD class="r b data"&gt;10.53&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l t rowheader" scope="row"&gt;15&lt;/TH&gt;
&lt;TD class="r b data"&gt;10.53&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l t rowheader" rowspan="7" scope="rowgroup"&gt;M&lt;/TH&gt;
&lt;TH class="l t rowheader" scope="row"&gt;All&lt;/TH&gt;
&lt;TD class="r b data"&gt;52.63&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l t rowheader" scope="row"&gt;11&lt;/TH&gt;
&lt;TD class="r b data"&gt;5.26&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l t rowheader" scope="row"&gt;12&lt;/TH&gt;
&lt;TD class="r b data"&gt;15.79&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l t rowheader" scope="row"&gt;13&lt;/TH&gt;
&lt;TD class="r b data"&gt;5.26&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l t rowheader" scope="row"&gt;14&lt;/TH&gt;
&lt;TD class="r b data"&gt;10.53&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l t rowheader" scope="row"&gt;15&lt;/TH&gt;
&lt;TD class="r b data"&gt;10.53&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l t rowheader" scope="row"&gt;16&lt;/TH&gt;
&lt;TD class="r b data"&gt;5.26&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Wed, 01 Jun 2016 04:11:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Group-and-subgroups-coding/m-p/274273#M54702</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2016-06-01T04:11:42Z</dc:date>
    </item>
  </channel>
</rss>

