<?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: How to - Divide Data Set Equal Groups By Getting Default Counts and Min and Max Ranges? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-Divide-Data-Set-Equal-Groups-By-Getting-Default-Counts/m-p/495316#M130700</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC MEANS DATA=Ranked_Have NWAY  N NMISS MEAN MIN MAX STACKODS;
CLASS BUCKET;
VAR SCORE TARGET ;
ods output summary=ranked_stats;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/48505"&gt;@turcay&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried something but it does not work. Could you tell where should I put N, NMISS and SUM function in the following procedure?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC MEANS DATA=Ranked_Have NOPRINT MIN MAX N NMISS SUM	; 
CLASS BUCKET;
VAR SCORE;
VAR Target;
OUTPUT OUT=RANGES SUM=Target NMISS=Target MIN=MIN MAX=MAX ;
RUN;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 13 Sep 2018 14:40:56 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-09-13T14:40:56Z</dc:date>
    <item>
      <title>How to - Divide Data Set Equal Groups By Getting Default Counts and Min and Max Ranges?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Divide-Data-Set-Equal-Groups-By-Getting-Default-Counts/m-p/494906#M130506</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My purpose is to divide the table 3 equal groups depending on one variable. On the other hand, I would like to see my Target variable 1 and 0 values. Additively, I also want to see ranges(Min and Max) for every groups.&amp;nbsp; My desired output as below;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Desired.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/23218i91897D4B53368FF7/image-size/large?v=v2&amp;amp;px=999" role="button" title="Desired.png" alt="Desired.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I prepared a sample data, first I used PROC RANK procedure and then I used PROC MEANS I can get Min and Max ranges and Total Count but I cannot get count values for 1 and 0 for my Target variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data Have;
Length Score 8 Target 8;
Infile Datalines missover;
Input Score Target;
Datalines;
1200 1
1210 0
1220 1
1230 0
1240 1
1250 0
1260 1
1270 0
1280 1
1290 0
1300 0
1310 1
1320 0
1330 0
1340 1
1350 0
1360 0
1370 1
1380 0
1390 0
1400 1
1410 0
1420 0
1430 0
1440 1
1450 0
1460 0
1470 0
1480 1
1490 0
1500 0
;
Run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC RANK DATA=Have Groups=3 Out=Ranked_Have;
Var Score;
Ranks Bucket;
Run;

PROC MEANS DATA=Ranked_Have NWAY NOPRINT;
CLASS BUCKET;
VAR SCORE;
OUTPUT OUT=RANGES MIN=MIN MAX=MAX;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then I tried PROC TABULATE procudure and some addition steps to reach my aim. However, this time, I could not get ranges(Max and Min).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC TABULATE DATA=Ranked_Have Out=DefaultCounts(DROP=_TYPE_ _PAGE_ _TABLE_);
	CLASS Target / Order=Unformatted Missing;
	CLASS Bucket / Order=Unformatted Missing;
	TABLE Bucket,
		Target*N ALL={LABEL="Total (ALL)"}*N;
RUN;

PROC SORT DATA=DefaultCounts(KEEP=N BUCKET) OUT=SORTED_COUNT;
BY BUCKET;
RUN;

PROC TRANSPOSE DATA=SORTED_COUNT OUT=SORTED_COUNT2(DROP=_NAME_ RENAME=(TARGET1=NonDefault TARGET2=Default_Count TARGET3=Total_Count))
PREFIX=TARGET;
BY BUCKET;
VAR N;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Can anybody help me about this situation, please?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you,&lt;/P&gt;</description>
      <pubDate>Wed, 12 Sep 2018 16:10:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Divide-Data-Set-Equal-Groups-By-Getting-Default-Counts/m-p/494906#M130506</guid>
      <dc:creator>turcay</dc:creator>
      <dc:date>2018-09-12T16:10:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to - Divide Data Set Equal Groups By Getting Default Counts and Min and Max Ranges?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Divide-Data-Set-Equal-Groups-By-Getting-Default-Counts/m-p/494909#M130507</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;but I cannot get count values for 1 and 0 for my Target variable&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Number of 1s is the SUM of the TARGET variable.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Number of 0s is the N-SUM of the TARGET variable.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Add those additional statistics to your PROC MEANS and then in a data step do the subtraction to the get the number of 0's.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Or if you want to add a different&amp;nbsp;step you could try PROC FREQ.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Sep 2018 16:21:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Divide-Data-Set-Equal-Groups-By-Getting-Default-Counts/m-p/494909#M130507</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-09-12T16:21:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to - Divide Data Set Equal Groups By Getting Default Counts and Min and Max Ranges?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Divide-Data-Set-Equal-Groups-By-Getting-Default-Counts/m-p/495217#M130657</link>
      <description>&lt;P&gt;Thank you,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried something but it does not work. Could you tell where should I put N, NMISS and SUM function in the following procedure?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC MEANS DATA=Ranked_Have NOPRINT MIN MAX N NMISS SUM	; 
CLASS BUCKET;
VAR SCORE;
VAR Target;
OUTPUT OUT=RANGES SUM=Target NMISS=Target MIN=MIN MAX=MAX ;
RUN;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 Sep 2018 09:46:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Divide-Data-Set-Equal-Groups-By-Getting-Default-Counts/m-p/495217#M130657</guid>
      <dc:creator>turcay</dc:creator>
      <dc:date>2018-09-13T09:46:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to - Divide Data Set Equal Groups By Getting Default Counts and Min and Max Ranges?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Divide-Data-Set-Equal-Groups-By-Getting-Default-Counts/m-p/495316#M130700</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC MEANS DATA=Ranked_Have NWAY  N NMISS MEAN MIN MAX STACKODS;
CLASS BUCKET;
VAR SCORE TARGET ;
ods output summary=ranked_stats;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/48505"&gt;@turcay&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried something but it does not work. Could you tell where should I put N, NMISS and SUM function in the following procedure?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC MEANS DATA=Ranked_Have NOPRINT MIN MAX N NMISS SUM	; 
CLASS BUCKET;
VAR SCORE;
VAR Target;
OUTPUT OUT=RANGES SUM=Target NMISS=Target MIN=MIN MAX=MAX ;
RUN;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Sep 2018 14:40:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Divide-Data-Set-Equal-Groups-By-Getting-Default-Counts/m-p/495316#M130700</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-09-13T14:40:56Z</dc:date>
    </item>
  </channel>
</rss>

