<?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: Easy for an experienced SAS programmer, but not me. in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Easy-for-an-experienced-SAS-programmer-but-not-me/m-p/75368#M21856</link>
    <description>Use PROC SUMMARY to summarize your SAS table generating an output file, and PROC PRINT to generate your report from the summary-level file generated by PROC SUMMARY.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
    <pubDate>Tue, 24 Feb 2009 22:51:06 GMT</pubDate>
    <dc:creator>sbb</dc:creator>
    <dc:date>2009-02-24T22:51:06Z</dc:date>
    <item>
      <title>Easy for an experienced SAS programmer, but not me.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Easy-for-an-experienced-SAS-programmer-but-not-me/m-p/75367#M21855</link>
      <description>The SAS-table variable Coulor can take the values Red, Blue, Green, Yellow, Black, White or Brown.&lt;BR /&gt;
&lt;BR /&gt;
Each month I want to run some SAS code that find the numbers of the three most frequent colours. They should be presented in alphabetical order. The numbers of the four other colours should be added under the name Others and placed on the last line.&lt;BR /&gt;
&lt;BR /&gt;
The output should look like this(the colours and their numbers should be presented in 2 columns):&lt;BR /&gt;
&lt;BR /&gt;
Example 1:&lt;BR /&gt;
&lt;BR /&gt;
Blue 178&lt;BR /&gt;
Brown 287&lt;BR /&gt;
Green 467&lt;BR /&gt;
Others 194&lt;BR /&gt;
&lt;BR /&gt;
Example 2:&lt;BR /&gt;
&lt;BR /&gt;
Green 502&lt;BR /&gt;
Red 341&lt;BR /&gt;
Yellow 761&lt;BR /&gt;
Others 510&lt;BR /&gt;
&lt;BR /&gt;
How should the code look like? &lt;BR /&gt;
&lt;BR /&gt;
Susan</description>
      <pubDate>Tue, 24 Feb 2009 19:50:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Easy-for-an-experienced-SAS-programmer-but-not-me/m-p/75367#M21855</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-02-24T19:50:13Z</dc:date>
    </item>
    <item>
      <title>Re: Easy for an experienced SAS programmer, but not me.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Easy-for-an-experienced-SAS-programmer-but-not-me/m-p/75368#M21856</link>
      <description>Use PROC SUMMARY to summarize your SAS table generating an output file, and PROC PRINT to generate your report from the summary-level file generated by PROC SUMMARY.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Tue, 24 Feb 2009 22:51:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Easy-for-an-experienced-SAS-programmer-but-not-me/m-p/75368#M21856</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-02-24T22:51:06Z</dc:date>
    </item>
    <item>
      <title>Re: Easy for an experienced SAS programmer, but not me.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Easy-for-an-experienced-SAS-programmer-but-not-me/m-p/75369#M21857</link>
      <description>There may be better way but you need to count the colors then pool the ones that are not in the top three.  Notice the ORDER= options in the PROC SUMMAY steps that's what makes it work.&lt;BR /&gt;
&lt;BR /&gt;
It gives a different answer each time it is run.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
proc plan;&lt;BR /&gt;
   factors n=1000 ordered color = 1 of 12 / noprint;&lt;BR /&gt;
   output out=colors color cvals=("BLACK" "WHITE" "RED" "GREEN" "BLUE" "CYAN" "MAGENTA" "GRAY" "PINK" "ORANGE" "BROWN" "YELLOW");&lt;BR /&gt;
   run;&lt;BR /&gt;
proc summary data=colors nway order=freq;&lt;BR /&gt;
   class color;&lt;BR /&gt;
   output out=freq(drop=_type_);&lt;BR /&gt;
   run;&lt;BR /&gt;
proc print;&lt;BR /&gt;
   run;&lt;BR /&gt;
data freqV / view=freqV;&lt;BR /&gt;
   set freq;&lt;BR /&gt;
   if _n_ gt 3 then color='Other';&lt;BR /&gt;
   run;&lt;BR /&gt;
proc summary data=freqV nway order=data;&lt;BR /&gt;
   class color;&lt;BR /&gt;
   output out=freq4(drop=_type_);&lt;BR /&gt;
   freq _freq_;&lt;BR /&gt;
   run;&lt;BR /&gt;
proc print;&lt;BR /&gt;
   run;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Tue, 24 Feb 2009 22:58:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Easy-for-an-experienced-SAS-programmer-but-not-me/m-p/75369#M21857</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2009-02-24T22:58:40Z</dc:date>
    </item>
    <item>
      <title>Re: Easy for an experienced SAS programmer, but not me.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Easy-for-an-experienced-SAS-programmer-but-not-me/m-p/75370#M21858</link>
      <description>&amp;gt; They should be presented in alphabetical order.&lt;BR /&gt;
&lt;BR /&gt;
Sorry I missed that part.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
proc plan;&lt;BR /&gt;
   factors n=1000 ordered color = 1 of 12 / noprint;&lt;BR /&gt;
   output out=colors color cvals=("BLACK" "WHITE" "RED" "GREEN" "BLUE" "CYAN" "MAGENTA" "GRAY" "PINK" "ORANGE" "BROWN" "YELLOW");&lt;BR /&gt;
   run;&lt;BR /&gt;
proc summary data=colors nway order=freq;&lt;BR /&gt;
   class color;&lt;BR /&gt;
   output out=freq(drop=_type_);&lt;BR /&gt;
   run;&lt;BR /&gt;
proc print;&lt;BR /&gt;
   run;&lt;BR /&gt;
&lt;B&gt;proc format;&lt;BR /&gt;
   value $color(default=12) 'ff'x='Other';&lt;BR /&gt;
   run;&lt;/B&gt;&lt;BR /&gt;
data freqV / view=freqV;&lt;BR /&gt;
   set freq;&lt;BR /&gt;
&lt;B&gt;   if _n_ gt 3 then color='ff'x;&lt;/B&gt;   &lt;BR /&gt;
   run;&lt;BR /&gt;
proc summary data=freqV nway &lt;B&gt;order=internal&lt;/B&gt;;&lt;BR /&gt;
   class color;&lt;BR /&gt;
   &lt;B&gt;format color $color.&lt;/B&gt;;&lt;BR /&gt;
   output out=freq4(drop=_type_);&lt;BR /&gt;
   freq _freq_;&lt;BR /&gt;
   run;&lt;BR /&gt;
proc print;&lt;BR /&gt;
   run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;I&gt;Obs    color    _FREQ_&lt;BR /&gt;
&lt;BR /&gt;
 1     BLACK      100&lt;BR /&gt;
 2     BROWN      100&lt;BR /&gt;
 3     WHITE       94&lt;BR /&gt;
 4     Other      706&lt;/I&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
[/pre]</description>
      <pubDate>Wed, 25 Feb 2009 02:25:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Easy-for-an-experienced-SAS-programmer-but-not-me/m-p/75370#M21858</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2009-02-25T02:25:30Z</dc:date>
    </item>
    <item>
      <title>Re: Easy for an experienced SAS programmer, but not me.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Easy-for-an-experienced-SAS-programmer-but-not-me/m-p/75371#M21859</link>
      <description>Thankyou!&lt;BR /&gt;
&lt;BR /&gt;
But 706 / 4 &amp;gt; 176 &lt;B&gt;.&lt;BR /&gt;
&lt;BR /&gt;
: ) Susan&lt;BR /&gt;
&lt;BR /&gt;
&lt;I&gt;Obs    color    _FREQ_ &lt;BR /&gt;
1     BLACK        100 &lt;BR /&gt;
2     BROWN      100 &lt;BR /&gt;
3     WHITE          94 &lt;BR /&gt;
4     Other          706&lt;/I&gt;&lt;/B&gt;</description>
      <pubDate>Wed, 25 Feb 2009 08:46:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Easy-for-an-experienced-SAS-programmer-but-not-me/m-p/75371#M21859</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-02-25T08:46:07Z</dc:date>
    </item>
    <item>
      <title>Re: Easy for an experienced SAS programmer, but not me.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Easy-for-an-experienced-SAS-programmer-but-not-me/m-p/75372#M21860</link>
      <description>Oh, yes.&lt;BR /&gt;
&lt;BR /&gt;
Now I notice; you had 12 colours. Sorry.&lt;BR /&gt;
&lt;BR /&gt;
Susan</description>
      <pubDate>Wed, 25 Feb 2009 08:50:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Easy-for-an-experienced-SAS-programmer-but-not-me/m-p/75372#M21860</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-02-25T08:50:33Z</dc:date>
    </item>
  </channel>
</rss>

