<?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: Print the details with the least count group. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Print-the-details-with-the-least-count-group/m-p/332029#M271985</link>
    <description>&lt;P&gt;* print detail data for the category with the least observations;&lt;/P&gt;
&lt;P&gt;* you can do this in one proc sql but not using a report like proc print;&lt;/P&gt;
&lt;P&gt;%symdel sex;&lt;BR /&gt;proc sql;&lt;BR /&gt; select&lt;BR /&gt; sex into :sex separated by ""&lt;BR /&gt; from (&lt;BR /&gt; select&lt;BR /&gt; sex&lt;BR /&gt; ,count(sex) as sexcnt&lt;BR /&gt; from&lt;BR /&gt; sashelp.class&lt;BR /&gt; group&lt;BR /&gt; by sex&lt;BR /&gt; )&lt;BR /&gt; having&lt;BR /&gt; sexcnt= min(sexcnt)&lt;BR /&gt;;quit;&lt;/P&gt;
&lt;P&gt;proc print data=sashelp.class(where=(sex="&amp;amp;sex"));&lt;BR /&gt;run;quit;&lt;/P&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;P&gt;* this tends to be more flexible;&lt;BR /&gt;* stored program;&lt;BR /&gt;* dosubl with a 'libname' command;&lt;/P&gt;
&lt;P&gt;%symdel sex;&lt;BR /&gt;data _null_;&lt;/P&gt;
&lt;P&gt;rc=dosubl('&lt;BR /&gt; %symdel sex;&lt;BR /&gt; proc sql;&lt;BR /&gt; select&lt;BR /&gt; sex into :sex separated by ""&lt;BR /&gt; from (&lt;BR /&gt; select&lt;BR /&gt; sex&lt;BR /&gt; ,count(sex) as sexcnt&lt;BR /&gt; from&lt;BR /&gt; sashelp.class&lt;BR /&gt; group&lt;BR /&gt; by sex&lt;BR /&gt; )&lt;BR /&gt; having&lt;BR /&gt; sexcnt= max(sexcnt)&lt;BR /&gt; ;quit;&lt;BR /&gt; ');&lt;/P&gt;
&lt;P&gt;sexmax=symget('sex');&lt;BR /&gt; call symputx('sexmax',sexmax); * pass to dosubl;&lt;/P&gt;
&lt;P&gt;rc=dosubl('&lt;BR /&gt; proc print data=sashelp.class(where=(sex="&amp;amp;sexmax"));&lt;BR /&gt; run;quit;&lt;BR /&gt; ');&lt;/P&gt;
&lt;P&gt;run;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 12 Feb 2017 22:11:52 GMT</pubDate>
    <dc:creator>rogerjdeangelis</dc:creator>
    <dc:date>2017-02-12T22:11:52Z</dc:date>
    <item>
      <title>Print the details with the least count group.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Print-the-details-with-the-least-count-group/m-p/331896#M271981</link>
      <description>&lt;P&gt;Say I have a variable x in a data set, I use PROC FREQ to sort the dataset.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC FREQ MyData;
  tables x;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;So I get the frequencies. Say x has three groups. Group one has 4, group two has 24, group three has 59. Now I want to print the details (names and ages) with the smallest count group(group one). How?&lt;/P&gt;</description>
      <pubDate>Sun, 12 Feb 2017 00:40:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Print-the-details-with-the-least-count-group/m-p/331896#M271981</guid>
      <dc:creator>sas_newbie3</dc:creator>
      <dc:date>2017-02-12T00:40:25Z</dc:date>
    </item>
    <item>
      <title>Re: Print the details with the least count group.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Print-the-details-with-the-least-count-group/m-p/331897#M271982</link>
      <description>&lt;P&gt;Proc freq doesn't sort a dataset and that code, as posted, is incorrect.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can apply a WHERE to filter your dataset.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data want;
Set mydata;
Where group = 1;
Run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you wanted this to be automatic/dynamic it's probably easiest to use a SQL query instead.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 12 Feb 2017 00:50:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Print-the-details-with-the-least-count-group/m-p/331897#M271982</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-02-12T00:50:05Z</dc:date>
    </item>
    <item>
      <title>Re: Print the details with the least count group.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Print-the-details-with-the-least-count-group/m-p/331899#M271983</link>
      <description>&lt;P&gt;What is &lt;STRONG&gt;group&lt;/STRONG&gt; in your code? I get an error. Variable &lt;STRONG&gt;group&lt;/STRONG&gt; is not on the file xxxxxx. By the way, I haven't learnt sql yet.&lt;/P&gt;</description>
      <pubDate>Sun, 12 Feb 2017 01:05:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Print-the-details-with-the-least-count-group/m-p/331899#M271983</guid>
      <dc:creator>sas_newbie3</dc:creator>
      <dc:date>2017-02-12T01:05:21Z</dc:date>
    </item>
    <item>
      <title>Re: Print the details with the least count group.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Print-the-details-with-the-least-count-group/m-p/331901#M271984</link>
      <description>&lt;P&gt;In your example, let say X has values like: 'S', 'L','B' and&lt;/P&gt;
&lt;P&gt;the 3 frequency groups are: S freq=is 4, &amp;nbsp;L freq=24, &amp;nbsp;B freq=59.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now you are looking for details of group where X='S', i.e.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Title "Data for group with x=S ";
proc print data=have (where=(x='S'));
&amp;nbsp; var &amp;nbsp;... enter here variables to print in desired order saparated by space ...;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 12 Feb 2017 01:25:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Print-the-details-with-the-least-count-group/m-p/331901#M271984</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-02-12T01:25:46Z</dc:date>
    </item>
    <item>
      <title>Re: Print the details with the least count group.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Print-the-details-with-the-least-count-group/m-p/332029#M271985</link>
      <description>&lt;P&gt;* print detail data for the category with the least observations;&lt;/P&gt;
&lt;P&gt;* you can do this in one proc sql but not using a report like proc print;&lt;/P&gt;
&lt;P&gt;%symdel sex;&lt;BR /&gt;proc sql;&lt;BR /&gt; select&lt;BR /&gt; sex into :sex separated by ""&lt;BR /&gt; from (&lt;BR /&gt; select&lt;BR /&gt; sex&lt;BR /&gt; ,count(sex) as sexcnt&lt;BR /&gt; from&lt;BR /&gt; sashelp.class&lt;BR /&gt; group&lt;BR /&gt; by sex&lt;BR /&gt; )&lt;BR /&gt; having&lt;BR /&gt; sexcnt= min(sexcnt)&lt;BR /&gt;;quit;&lt;/P&gt;
&lt;P&gt;proc print data=sashelp.class(where=(sex="&amp;amp;sex"));&lt;BR /&gt;run;quit;&lt;/P&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;P&gt;* this tends to be more flexible;&lt;BR /&gt;* stored program;&lt;BR /&gt;* dosubl with a 'libname' command;&lt;/P&gt;
&lt;P&gt;%symdel sex;&lt;BR /&gt;data _null_;&lt;/P&gt;
&lt;P&gt;rc=dosubl('&lt;BR /&gt; %symdel sex;&lt;BR /&gt; proc sql;&lt;BR /&gt; select&lt;BR /&gt; sex into :sex separated by ""&lt;BR /&gt; from (&lt;BR /&gt; select&lt;BR /&gt; sex&lt;BR /&gt; ,count(sex) as sexcnt&lt;BR /&gt; from&lt;BR /&gt; sashelp.class&lt;BR /&gt; group&lt;BR /&gt; by sex&lt;BR /&gt; )&lt;BR /&gt; having&lt;BR /&gt; sexcnt= max(sexcnt)&lt;BR /&gt; ;quit;&lt;BR /&gt; ');&lt;/P&gt;
&lt;P&gt;sexmax=symget('sex');&lt;BR /&gt; call symputx('sexmax',sexmax); * pass to dosubl;&lt;/P&gt;
&lt;P&gt;rc=dosubl('&lt;BR /&gt; proc print data=sashelp.class(where=(sex="&amp;amp;sexmax"));&lt;BR /&gt; run;quit;&lt;BR /&gt; ');&lt;/P&gt;
&lt;P&gt;run;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 12 Feb 2017 22:11:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Print-the-details-with-the-least-count-group/m-p/332029#M271985</guid>
      <dc:creator>rogerjdeangelis</dc:creator>
      <dc:date>2017-02-12T22:11:52Z</dc:date>
    </item>
  </channel>
</rss>

