<?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: Problems with proc summary, total, other and order :) in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Problems-with-proc-summary-total-other-and-order/m-p/39970#M10345</link>
    <description>Hi to all,&lt;BR /&gt;
thank you for your answer! I've found to be part of the problem the use of the preloadfmt, and I've solved 90% of the problems found.&lt;BR /&gt;
Unfortunately, I cannot post the code...it's too much complicated and confused by macro code, and it would be just an headache for each one who would try to help me :).&lt;BR /&gt;
&lt;BR /&gt;
Cynthia, your code looks quite interesting, but I've to ask something about the "notsorted" option: actually, we've got a program running each night which updates the formats.&lt;BR /&gt;
However, we update the format using the cntlin option: we have prepared a table (downloaded from a SQL Server) which contains the minimum fields for creating a format...which field should I had for the "notsorted"?&lt;BR /&gt;
Thanks&lt;BR /&gt;
&lt;BR /&gt;
Daniele</description>
    <pubDate>Wed, 13 Jan 2010 18:00:33 GMT</pubDate>
    <dc:creator>DanieleTiles</dc:creator>
    <dc:date>2010-01-13T18:00:33Z</dc:date>
    <item>
      <title>Problems with proc summary, total, other and order :)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problems-with-proc-summary-total-other-and-order/m-p/39967#M10342</link>
      <description>Hi to all,&lt;BR /&gt;
we've got a problem on how to render a set of tabulates...let me explain: we've got to plot a table which shows, for city and year, the percentage of family with one person over the total of the families. We've than applied the proc summary, and got in this way the correct percentage :).&lt;BR /&gt;
However, we need to apply a format to the cities, which groups the city for "association": we have this format which says for each city the correct association and:&lt;BR /&gt;
 - with start/end value of 999999 we point to the "All" association (in order to group them and show them in this kind of table...never let tabulate sum a percentage)&lt;BR /&gt;
-  with an entry of "No association" for the cities which don't apply to any format (it's a format with the Other option: no start or end).&lt;BR /&gt;
This seems to work pretty well, except for the order on which the class variables are printed :(...unfortunately, the "No association" label is ALWAYS after the "All" label...and we are struggling to find a way to order in the other way!  But even saying that order has to be "data" in the proc tabulate, and seeing that last observations are the total one...it doesn't work :(.&lt;BR /&gt;
Any idea?&lt;BR /&gt;
Thanks&lt;BR /&gt;
&lt;BR /&gt;
Daniele</description>
      <pubDate>Wed, 13 Jan 2010 14:01:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problems-with-proc-summary-total-other-and-order/m-p/39967#M10342</guid>
      <dc:creator>DanieleTiles</dc:creator>
      <dc:date>2010-01-13T14:01:21Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with proc summary, total, other and order :)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problems-with-proc-summary-total-other-and-order/m-p/39968#M10343</link>
      <description>Share your code by pasting it into another REPLY with this post.&lt;BR /&gt;
&lt;BR /&gt;
If you intend to chart/report values differently than in alphabetic-order, you will need to construct a FORMAT (numeric most likely) and assign representative values to achieve your desired order/sequence.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
Google advanced search argument suggested:&lt;BR /&gt;
&lt;BR /&gt;
chart data values using format site:sas.com</description>
      <pubDate>Wed, 13 Jan 2010 14:57:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problems-with-proc-summary-total-other-and-order/m-p/39968#M10343</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-01-13T14:57:37Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with proc summary, total, other and order :)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problems-with-proc-summary-total-other-and-order/m-p/39969#M10344</link>
      <description>Hi:&lt;BR /&gt;
  I'm not entirely sure I understand what you want, but this note describes how to use PRELOADFMT and ORDER=DATA to ensure that you get the order you want with multi-label formats. &lt;BR /&gt;
&lt;A href="http://support.sas.com/kb/12/904.html" target="_blank"&gt;http://support.sas.com/kb/12/904.html&lt;/A&gt;&lt;BR /&gt;
              &lt;BR /&gt;
The simplified code below shows how to use TABULATE to get the formats in the order you want, with regular formats and with multilabel formats. The PRELOADFMT option loads the format as it is stored and the NOTSORTED in PROC FORMAT ensures that the format is stored in the order you defined. Either with or without multi-label formats, you can get the CLASS variables in the order you want.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia&lt;BR /&gt;
 [pre]&lt;BR /&gt;
proc format;&lt;BR /&gt;
value agemlf (multilabel notsorted)&lt;BR /&gt;
   11-12='pre-teen'&lt;BR /&gt;
   13-19='teenager'&lt;BR /&gt;
   11-14='non-driver'&lt;BR /&gt;
   15-high='driver';&lt;BR /&gt;
                            &lt;BR /&gt;
value regage (notsorted)&lt;BR /&gt;
   11-12 = 'Z'&lt;BR /&gt;
   13-14 = 'A'&lt;BR /&gt;
   15-high='H';&lt;BR /&gt;
run;&lt;BR /&gt;
                        &lt;BR /&gt;
proc sort data=sashelp.class out=class;&lt;BR /&gt;
by age;&lt;BR /&gt;
run;&lt;BR /&gt;
                 &lt;BR /&gt;
proc tabulate data=class;&lt;BR /&gt;
  title 'PRELOADFMT and Formats In My Order';&lt;BR /&gt;
  class age / preloadfmt order=data;&lt;BR /&gt;
  var height;&lt;BR /&gt;
  table height*(min mean max),&lt;BR /&gt;
        age;&lt;BR /&gt;
  format age regage.;&lt;BR /&gt;
run;&lt;BR /&gt;
                             &lt;BR /&gt;
proc tabulate data=class;&lt;BR /&gt;
  title 'Using MLF and PRELOADFMT and Formats in My Order';&lt;BR /&gt;
  class age / mlf preloadfmt order=data;&lt;BR /&gt;
  var height;&lt;BR /&gt;
  table height*(min mean max),&lt;BR /&gt;
        age;&lt;BR /&gt;
  format age agemlf.;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Wed, 13 Jan 2010 17:31:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problems-with-proc-summary-total-other-and-order/m-p/39969#M10344</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-01-13T17:31:15Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with proc summary, total, other and order :)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problems-with-proc-summary-total-other-and-order/m-p/39970#M10345</link>
      <description>Hi to all,&lt;BR /&gt;
thank you for your answer! I've found to be part of the problem the use of the preloadfmt, and I've solved 90% of the problems found.&lt;BR /&gt;
Unfortunately, I cannot post the code...it's too much complicated and confused by macro code, and it would be just an headache for each one who would try to help me :).&lt;BR /&gt;
&lt;BR /&gt;
Cynthia, your code looks quite interesting, but I've to ask something about the "notsorted" option: actually, we've got a program running each night which updates the formats.&lt;BR /&gt;
However, we update the format using the cntlin option: we have prepared a table (downloaded from a SQL Server) which contains the minimum fields for creating a format...which field should I had for the "notsorted"?&lt;BR /&gt;
Thanks&lt;BR /&gt;
&lt;BR /&gt;
Daniele</description>
      <pubDate>Wed, 13 Jan 2010 18:00:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problems-with-proc-summary-total-other-and-order/m-p/39970#M10345</guid>
      <dc:creator>DanieleTiles</dc:creator>
      <dc:date>2010-01-13T18:00:33Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with proc summary, total, other and order :)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problems-with-proc-summary-total-other-and-order/m-p/39971#M10346</link>
      <description>An easy way to figure out what variables and values are needed for a CNTLIN data set is to look at a CNTLOUT data for similar formats/informats.  I believe the answer to your question is to include S in the HLO variable.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
&lt;BR /&gt;
      F                                          &lt;BR /&gt;
      M                                          &lt;BR /&gt;
      T      S                       L           &lt;BR /&gt;
      N      T                       A           &lt;BR /&gt;
O     A      A           E           B             H&lt;BR /&gt;
b     M      R           N           E             L&lt;BR /&gt;
s     E      T           D           L             O&lt;BR /&gt;
&lt;BR /&gt;
1   AGEMLF   11                 12   pre-teen      SM&lt;BR /&gt;
2   AGEMLF   13                 19   teenager      SM&lt;BR /&gt;
3   AGEMLF   11                 14   non-driver    SM&lt;BR /&gt;
4   AGEMLF   15   HIGH               driver        SMH&lt;BR /&gt;
5   REGAGE   11                 12   Z             S&lt;BR /&gt;
6   REGAGE   13                 14   A             S&lt;BR /&gt;
7   REGAGE   15   HIGH               H             SH&lt;BR /&gt;
&lt;BR /&gt;
[/pre]</description>
      <pubDate>Wed, 13 Jan 2010 18:52:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problems-with-proc-summary-total-other-and-order/m-p/39971#M10346</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2010-01-13T18:52:31Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with proc summary, total, other and order :)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problems-with-proc-summary-total-other-and-order/m-p/39972#M10347</link>
      <description>Hi to all,&lt;BR /&gt;
in the end we solved our problem by changing our format and avoiding using the "other" option in the formats...but still, I'd like to understand what I'm missing here.&lt;BR /&gt;
Consider this sample code:&lt;BR /&gt;
&lt;BR /&gt;
//////////////////////////////////////////////////////////////////////////&lt;BR /&gt;
&lt;BR /&gt;
proc format cntlout=work.fmt;&lt;BR /&gt;
	value $first (notsorted) '1' = 'First'&lt;BR /&gt;
				 other = 'None'&lt;BR /&gt;
				 '999' = 'Total';&lt;BR /&gt;
&lt;BR /&gt;
		value $second (notsorted) '2' = 'Second'&lt;BR /&gt;
				 other = 'None'&lt;BR /&gt;
				 '999' = 'Total';&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data test;&lt;BR /&gt;
	length first $8.;&lt;BR /&gt;
	length second $8.;&lt;BR /&gt;
	length num 8.;&lt;BR /&gt;
	input first second num @@;&lt;BR /&gt;
cards;&lt;BR /&gt;
4 4 20&lt;BR /&gt;
5 6 10&lt;BR /&gt;
1 2 10&lt;BR /&gt;
1 2 10&lt;BR /&gt;
3 3 40&lt;BR /&gt;
999 999 90&lt;BR /&gt;
;&lt;BR /&gt;
&lt;BR /&gt;
proc tabulate data=test;&lt;BR /&gt;
	class first / preloadfmt order=data;&lt;BR /&gt;
	class second / preloadfmt order=data;&lt;BR /&gt;
	var num;&lt;BR /&gt;
	table first='', second=''*num=''*sum='';&lt;BR /&gt;
	format first $first.;&lt;BR /&gt;
	format second $second.;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
//////////////////////////////////////////////////////////////////////////&lt;BR /&gt;
&lt;BR /&gt;
What I expect (or would like) is a cross-table like thi one:&lt;BR /&gt;
&lt;BR /&gt;
_______|  Second  |  None  | Total&lt;BR /&gt;
   First    |                |             |&lt;BR /&gt;
   None  |                |             |  &lt;BR /&gt;
   Total  |                |              |&lt;BR /&gt;
&lt;BR /&gt;
Instead, what I get is this:&lt;BR /&gt;
&lt;BR /&gt;
_______|  Second  |  Total  | None&lt;BR /&gt;
   First    |                |             |&lt;BR /&gt;
   Total |                |             |  &lt;BR /&gt;
   None  |                |              |&lt;BR /&gt;
&lt;BR /&gt;
What I'm doing wrong, missing?&lt;BR /&gt;
Thanks&lt;BR /&gt;
&lt;BR /&gt;
Daniele</description>
      <pubDate>Thu, 14 Jan 2010 20:41:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problems-with-proc-summary-total-other-and-order/m-p/39972#M10347</guid>
      <dc:creator>DanieleTiles</dc:creator>
      <dc:date>2010-01-14T20:41:20Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with proc summary, total, other and order :)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problems-with-proc-summary-total-other-and-order/m-p/39973#M10348</link>
      <description>Hi:&lt;BR /&gt;
  As I remember, OTHER is a special category. It is always last. You might have gotten around it by:&lt;BR /&gt;
[pre]&lt;BR /&gt;
proc format;&lt;BR /&gt;
value $first (notsorted) '1' = 'First'&lt;BR /&gt;
            2-998 = 'None'&lt;BR /&gt;
            '999' = 'Total';&lt;BR /&gt;
                  &lt;BR /&gt;
value $second (notsorted) '2' = 'Second'&lt;BR /&gt;
             1, 3-998 = 'None'&lt;BR /&gt;
            '999' = 'Total';&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
 &lt;BR /&gt;
I don't believe you can use OTHER for this situation, given that your data are structured the way they are. For other reports, I have done something like this:&lt;BR /&gt;
[pre]&lt;BR /&gt;
value $first (notsorted) '1' = 'First'&lt;BR /&gt;
            2-998 = 'None'&lt;BR /&gt;
            other = 'Total';&lt;BR /&gt;
[/pre]&lt;BR /&gt;
                 &lt;BR /&gt;
But, this assumes that you know, from the structure of the data that only the 999 obs are left and that you will -never- have a number greater than 999 being used with this format.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Thu, 14 Jan 2010 21:30:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problems-with-proc-summary-total-other-and-order/m-p/39973#M10348</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-01-14T21:30:31Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with proc summary, total, other and order :)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problems-with-proc-summary-total-other-and-order/m-p/39974#M10349</link>
      <description>Hi Cynthia,&lt;BR /&gt;
thank you very much for your answer! Finally, everything is explained :).&lt;BR /&gt;
This was of course a simplified problem: the real problem was that the format is dynamically updated every night, and so we are sure that there aren't any cities with code '999999' (our total format), but...maybe tonight the city 199 is inside a format, tomorrow it's outside any category and then it should fall back to the "other" category&lt;BR /&gt;
As we've got a complete list of the cities, we've done a simple code which associates each code of a city who doesn't fall into a format created by the user into a new "None" format, and we have created the format notsorted, ordered as we wanted. This is unfortunately less elegant than using the other format (which I found brilliant, until I was asked this particular order...), but it's still the best solution we could find.&lt;BR /&gt;
Again, thanks for unveiling the problem &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Thu, 14 Jan 2010 21:47:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problems-with-proc-summary-total-other-and-order/m-p/39974#M10349</guid>
      <dc:creator>DanieleTiles</dc:creator>
      <dc:date>2010-01-14T21:47:49Z</dc:date>
    </item>
  </channel>
</rss>

