<?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: Need only 12 observations how do I limit it. in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Need-only-12-observations-how-do-I-limit-it/m-p/73520#M21311</link>
    <description>Hi:&lt;BR /&gt;
  PROC FREQ is, essentially, creating a summary report -- given your code. There are no "observations" coming out of PROC FREQ -- FREQ is producing a report that can have titles and footnotes -- but essentially, just a REPORT. &lt;BR /&gt;
&lt;BR /&gt;
 If you wanted to create an output dataset, using PROC FREQ, then you would need to investigate how the OUT= option works or how the ODS OUTPUT destination works to create an OUTPUT dataset.&lt;BR /&gt;
&lt;BR /&gt;
PROC FREQ does support WHERE statement processing. So these would all be valid PROC FREQs:&lt;BR /&gt;
[pre]&lt;BR /&gt;
proc freq data=sashelp.class;&lt;BR /&gt;
  where sex = 'F';&lt;BR /&gt;
  tables age;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc freq data=sashelp.shoes;&lt;BR /&gt;
  where sales gt 10000;&lt;BR /&gt;
  tables product;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
 &lt;BR /&gt;
Also, I'm not sure I understand what you want. If you had this data (sorted in descending order) what would you envision:&lt;BR /&gt;
[pre]&lt;BR /&gt;
id   num&lt;BR /&gt;
a1 1000&lt;BR /&gt;
b2  999&lt;BR /&gt;
c3  998&lt;BR /&gt;
d4  997&lt;BR /&gt;
e5  996&lt;BR /&gt;
f6  995&lt;BR /&gt;
g7  994&lt;BR /&gt;
h8  993&lt;BR /&gt;
i9  992&lt;BR /&gt;
j10 991&lt;BR /&gt;
k11 990&lt;BR /&gt;
l12 989&lt;BR /&gt;
m13 988&lt;BR /&gt;
n14 987&lt;BR /&gt;
a1   14&lt;BR /&gt;
b2   13&lt;BR /&gt;
c3   12&lt;BR /&gt;
d4   11&lt;BR /&gt;
e5   10&lt;BR /&gt;
f6   9&lt;BR /&gt;
g7   8&lt;BR /&gt;
h8   7&lt;BR /&gt;
i9   6&lt;BR /&gt;
j10  5&lt;BR /&gt;
k11  4&lt;BR /&gt;
l12  3&lt;BR /&gt;
m13  2&lt;BR /&gt;
n14  1&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
  Possible outputs:&lt;BR /&gt;
1) only the first 12 with the highest values for num. In this scenario, you would pick off the first 12 observations from the detail data and either create a report or an output dataset;&lt;BR /&gt;
2) add up all the values for num by id and THEN pick off the highest 12 -- for example, in this scenario, ID of A1 would have a value of 1014 for NUM (the sum of the 2 observations for ID=AI) -- this could be either a report or an output dataset&lt;BR /&gt;
3) summarize all the values, find the IDs of the 12 highest and then go back and get ALL the observations for these highest IDs. In this scenario, you would have 2 observations for A1 on a report or in an output dataset: [pre]&lt;BR /&gt;
id   num&lt;BR /&gt;
a1 1000&lt;BR /&gt;
a1    14&lt;BR /&gt;
. . .&lt;BR /&gt;
[/pre]&lt;BR /&gt;
 &lt;BR /&gt;
Depending on the result you want, PROC FREQ may not be the path to follow.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
    <pubDate>Tue, 10 Feb 2009 21:18:32 GMT</pubDate>
    <dc:creator>Cynthia_sas</dc:creator>
    <dc:date>2009-02-10T21:18:32Z</dc:date>
    <item>
      <title>Need only 12 observations how do I limit it.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Need-only-12-observations-how-do-I-limit-it/m-p/73519#M21310</link>
      <description>Hi I need only 12 highest observations how and where do I put the statement to limit the number of observations.My code is below:&lt;BR /&gt;
&lt;BR /&gt;
Thanks.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
proc freq data = report.Fiscal08_datanodup order = freq;&lt;BR /&gt;
tables DIA_1;&lt;BR /&gt;
run;</description>
      <pubDate>Tue, 10 Feb 2009 19:11:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Need-only-12-observations-how-do-I-limit-it/m-p/73519#M21310</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-02-10T19:11:07Z</dc:date>
    </item>
    <item>
      <title>Re: Need only 12 observations how do I limit it.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Need-only-12-observations-how-do-I-limit-it/m-p/73520#M21311</link>
      <description>Hi:&lt;BR /&gt;
  PROC FREQ is, essentially, creating a summary report -- given your code. There are no "observations" coming out of PROC FREQ -- FREQ is producing a report that can have titles and footnotes -- but essentially, just a REPORT. &lt;BR /&gt;
&lt;BR /&gt;
 If you wanted to create an output dataset, using PROC FREQ, then you would need to investigate how the OUT= option works or how the ODS OUTPUT destination works to create an OUTPUT dataset.&lt;BR /&gt;
&lt;BR /&gt;
PROC FREQ does support WHERE statement processing. So these would all be valid PROC FREQs:&lt;BR /&gt;
[pre]&lt;BR /&gt;
proc freq data=sashelp.class;&lt;BR /&gt;
  where sex = 'F';&lt;BR /&gt;
  tables age;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc freq data=sashelp.shoes;&lt;BR /&gt;
  where sales gt 10000;&lt;BR /&gt;
  tables product;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
 &lt;BR /&gt;
Also, I'm not sure I understand what you want. If you had this data (sorted in descending order) what would you envision:&lt;BR /&gt;
[pre]&lt;BR /&gt;
id   num&lt;BR /&gt;
a1 1000&lt;BR /&gt;
b2  999&lt;BR /&gt;
c3  998&lt;BR /&gt;
d4  997&lt;BR /&gt;
e5  996&lt;BR /&gt;
f6  995&lt;BR /&gt;
g7  994&lt;BR /&gt;
h8  993&lt;BR /&gt;
i9  992&lt;BR /&gt;
j10 991&lt;BR /&gt;
k11 990&lt;BR /&gt;
l12 989&lt;BR /&gt;
m13 988&lt;BR /&gt;
n14 987&lt;BR /&gt;
a1   14&lt;BR /&gt;
b2   13&lt;BR /&gt;
c3   12&lt;BR /&gt;
d4   11&lt;BR /&gt;
e5   10&lt;BR /&gt;
f6   9&lt;BR /&gt;
g7   8&lt;BR /&gt;
h8   7&lt;BR /&gt;
i9   6&lt;BR /&gt;
j10  5&lt;BR /&gt;
k11  4&lt;BR /&gt;
l12  3&lt;BR /&gt;
m13  2&lt;BR /&gt;
n14  1&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
  Possible outputs:&lt;BR /&gt;
1) only the first 12 with the highest values for num. In this scenario, you would pick off the first 12 observations from the detail data and either create a report or an output dataset;&lt;BR /&gt;
2) add up all the values for num by id and THEN pick off the highest 12 -- for example, in this scenario, ID of A1 would have a value of 1014 for NUM (the sum of the 2 observations for ID=AI) -- this could be either a report or an output dataset&lt;BR /&gt;
3) summarize all the values, find the IDs of the 12 highest and then go back and get ALL the observations for these highest IDs. In this scenario, you would have 2 observations for A1 on a report or in an output dataset: [pre]&lt;BR /&gt;
id   num&lt;BR /&gt;
a1 1000&lt;BR /&gt;
a1    14&lt;BR /&gt;
. . .&lt;BR /&gt;
[/pre]&lt;BR /&gt;
 &lt;BR /&gt;
Depending on the result you want, PROC FREQ may not be the path to follow.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Tue, 10 Feb 2009 21:18:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Need-only-12-observations-how-do-I-limit-it/m-p/73520#M21311</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2009-02-10T21:18:32Z</dc:date>
    </item>
    <item>
      <title>Re: Need only 12 observations how do I limit it.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Need-only-12-observations-how-do-I-limit-it/m-p/73521#M21312</link>
      <description>Like Cynthia said you will need to make your own report.  But this could help get you started.  The out= data from PROC FREQ is in the order you desire and you can use OBS=12 data set option to subset the data.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
proc plan;&lt;BR /&gt;
   factors  DIA_1=20 freq=1 of 200 /noprint;&lt;BR /&gt;
   output out=dia;&lt;BR /&gt;
   run;&lt;BR /&gt;
proc freq order=freq;&lt;BR /&gt;
   tables  DIA_1 / out=top12;&lt;BR /&gt;
   weight freq;&lt;BR /&gt;
   run;&lt;BR /&gt;
proc print data=top12(obs=12);&lt;BR /&gt;
   run;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Wed, 11 Feb 2009 00:17:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Need-only-12-observations-how-do-I-limit-it/m-p/73521#M21312</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2009-02-11T00:17:48Z</dc:date>
    </item>
  </channel>
</rss>

