<?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: SAS code to create cutpoints in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/SAS-code-to-create-cutpoints/m-p/623335#M8752</link>
    <description>&lt;P&gt;Something like this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc rank data=subjinc out=subjrnk groups=3;
var income;
ranks subjgrp;
run;

proc format;
value incgrp
0 = "low income"
1 = "medium income"
2 = "high income";
run;

proc sql;
alter table subjrnk
modify subjgrp format=incgrp.;
quit;

proc tabulate data=subjrnk;
var income;
class subjgrp;
table (min*format=dollar6.0 max*format=dollar6.0 n*format=4.0),subjgrp=""*income="";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;  	low income 	medium income 	high income
Min 	$12896 	$19400 	$32145
Max 	$18998 	$27419 	$78362
N 	9 	10 	10&lt;/PRE&gt;</description>
    <pubDate>Sat, 08 Feb 2020 20:00:05 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2020-02-08T20:00:05Z</dc:date>
    <item>
      <title>SAS code to create cutpoints</title>
      <link>https://communities.sas.com/t5/SAS-Studio/SAS-code-to-create-cutpoints/m-p/623331#M8750</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I would appreciate if someone could help me with the SAS code to create tertiles (low income, medium income, high income) for dataset subjinc below and count the number of ca case pop cont and can cont. The SAS code and log are shown below: Table 1 output is attached.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My ultimate aim is to count the number of ca case, pop cont and can cont for low income (showing income range), medium income (showing income range) and&amp;nbsp; and high income (showing income range).&lt;/P&gt;
&lt;P&gt;Any help, please?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;
&lt;P&gt;ak.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;BR /&gt;/*  Suject income*/&lt;BR /&gt;data subjinc;&lt;BR /&gt;input id$ 1-5 job 7 income lung$ 15-22;&lt;BR /&gt;datalines;&lt;BR /&gt;OSa06 3 32356 Pop cont&lt;BR /&gt;OSa10 1	25689 Ca case&lt;BR /&gt;OSa11 1	18546 Ca case&lt;BR /&gt;OSa12 3	15756 Ca case&lt;BR /&gt;OSa13 3	14527 Ca case&lt;BR /&gt;OSa14 3	20458 Ca case&lt;BR /&gt;OSa29 2	56974 Ca cont&lt;BR /&gt;OSa30 4	34568 Ca cont&lt;BR /&gt;OSa31 4	69713 Ca cont&lt;BR /&gt;OSa32 1	12896 Ca case&lt;BR /&gt;OSa33 3	25684 Ca case&lt;BR /&gt;OSa34 3	78362 Ca case&lt;BR /&gt;OSa35 3	18998 Ca case&lt;BR /&gt;OSa54 3	26934 Pop cont&lt;BR /&gt;OSa73 3	65823 Pop cont&lt;BR /&gt;OSa86 3	23542 Ca cont&lt;BR /&gt;OSa93 3	14589 Pop cont&lt;BR /&gt;OSa94 3	14325 Pop cont&lt;BR /&gt;OSa95 4	45802 Pop cont&lt;BR /&gt;OSb02 1	27419 Ca cont&lt;BR /&gt;OSb16 1	15843 Ca case&lt;BR /&gt;OSb20 4	16560 Ca case&lt;BR /&gt;OSb38 3	21123 Ca cont&lt;BR /&gt;OSb39 3	19743 Ca cont&lt;BR /&gt;OSb58 1	36589 Pop cont&lt;BR /&gt;OSb70 1	32145 Ca cont&lt;BR /&gt;OSb71 2	19400 Ca cont&lt;BR /&gt;OSb72 3	21356 Ca cont&lt;BR /&gt;OSb73 4	70195 Ca cont&lt;BR /&gt;;&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;
&lt;DIV&gt;
&lt;DIV class="sasSource"&gt;
&lt;DIV&gt;
&lt;DIV class="sasSource"&gt;1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;72&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;73 /* Suject income*/&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV&gt;
&lt;DIV class="sasSource"&gt;74 data subjinc;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;75 input id$ 1-5 job 7 income lung$ 15-22;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;76 datalines;&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV id="sasLogNote1_1581186955618" class="sasNote"&gt;NOTE: The data set WORK.SUBJINC has 29 observations and 4 variables.&lt;/DIV&gt;
&lt;DIV id="sasLogNote2_1581186955618" class="sasNote"&gt;NOTE: DATA statement used (Total process time):&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;real time 0.01 seconds&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;cpu time 0.00 seconds&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;106 ;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;107&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;108 /* TASK 1: Creating cutpoints in entire dataset*/&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;109&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;110 data cutp; set subjinc;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;111&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV id="sasLogNote3_1581186955618" class="sasNote"&gt;NOTE: There were 29 observations read from the data set WORK.SUBJINC.&lt;/DIV&gt;
&lt;DIV id="sasLogNote4_1581186955618" class="sasNote"&gt;NOTE: The data set WORK.CUTP has 29 observations and 4 variables.&lt;/DIV&gt;
&lt;DIV id="sasLogNote5_1581186955618" class="sasNote"&gt;NOTE: DATA statement used (Total process time):&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;real time 0.01 seconds&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;cpu time 0.01 seconds&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;112 proc rank data=cutp out=cutp2 groups=3;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;113 var income;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;114 ranks rank2;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;115 run;&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV id="sasLogNote6_1581186955618" class="sasNote"&gt;NOTE: The data set WORK.CUTP2 has 29 observations and 5 variables.&lt;/DIV&gt;
&lt;DIV id="sasLogNote7_1581186955618" class="sasNote"&gt;NOTE: PROCEDURE RANK used (Total process time):&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;real time 0.01 seconds&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;cpu time 0.02 seconds&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;116&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;117 proc print data= cutp2;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;118 title ' Table 1: Subject income ranks';&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;119 run;&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV id="sasLogNote8_1581186955618" class="sasNote"&gt;NOTE: There were 29 observations read from the data set WORK.CUTP2.&lt;/DIV&gt;
&lt;DIV id="sasLogNote9_1581186955618" class="sasNote"&gt;NOTE: PROCEDURE PRINT used (Total process time):&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;real time 0.34 seconds&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;cpu time 0.34 seconds&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;120&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;121&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;122 data cutp3; set cutp2;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;123 if rank2 = 0 then incomerank ='low';&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;124 if rank2 = 1 then incomerank ='medium';&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;125 if rank2 = 2 then incomerank ='high';&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;126 run;&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV id="sasLogNote10_1581186955618" class="sasNote"&gt;NOTE: There were 29 observations read from the data set WORK.CUTP2.&lt;/DIV&gt;
&lt;DIV id="sasLogNote11_1581186955618" class="sasNote"&gt;NOTE: The data set WORK.CUTP3 has 29 observations and 6 variables.&lt;/DIV&gt;
&lt;DIV id="sasLogNote12_1581186955618" class="sasNote"&gt;NOTE: DATA statement used (Total process time):&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;real time 0.01 seconds&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;cpu time 0.01 seconds&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;127&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;128 /*TASK 2: COUNTING ca case, pop cont and can cont with dollar amount range:&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;129&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;130 low income range(.......), medium income range (.....), high income range (....)*/&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;131&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;132&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;133&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;134 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;146&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;PRE id="pre_sasLog_200" class="sasLog"&gt;&amp;nbsp;&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;PRE id="pre_sasLog_190" class="sasLog"&gt;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 08 Feb 2020 18:55:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/SAS-code-to-create-cutpoints/m-p/623331#M8750</guid>
      <dc:creator>ak2011</dc:creator>
      <dc:date>2020-02-08T18:55:06Z</dc:date>
    </item>
    <item>
      <title>Re: SAS code to create cutpoints</title>
      <link>https://communities.sas.com/t5/SAS-Studio/SAS-code-to-create-cutpoints/m-p/623334#M8751</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You don't seem to actually need cutpoints, since PROC RANK has put your data into 3 roughly equal-size groups.&amp;nbsp; Can't you just take the resulting ranked data set, and run a proc freq, cross-tabulating the variables of interest against rank2?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now, if you actually want cutpoints, then PROC UNIVARIATE is the way to go, as in:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc univariate data=subjinc noprint ;
  var income;
  output out=need pctlpts=33.3 66.7  pctlpre=pctl_ ;
run;
proc print;run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;which produces dataset NEED with one observations and two variables:&amp;nbsp; PCTL_33_3=19400&amp;nbsp;&amp;nbsp; and PCTL_66_7=32145.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could then&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
 set subjinc;
 if _n_=1 then set need;
 if .&amp;lt;income &amp;lt; pctl_33_3 then incgroup='Low'; else 
 if   income &amp;lt; pctl)66_7 then incgroup='Mid'; else
 incgroup='Hi';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 08 Feb 2020 19:52:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/SAS-code-to-create-cutpoints/m-p/623334#M8751</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2020-02-08T19:52:22Z</dc:date>
    </item>
    <item>
      <title>Re: SAS code to create cutpoints</title>
      <link>https://communities.sas.com/t5/SAS-Studio/SAS-code-to-create-cutpoints/m-p/623335#M8752</link>
      <description>&lt;P&gt;Something like this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc rank data=subjinc out=subjrnk groups=3;
var income;
ranks subjgrp;
run;

proc format;
value incgrp
0 = "low income"
1 = "medium income"
2 = "high income";
run;

proc sql;
alter table subjrnk
modify subjgrp format=incgrp.;
quit;

proc tabulate data=subjrnk;
var income;
class subjgrp;
table (min*format=dollar6.0 max*format=dollar6.0 n*format=4.0),subjgrp=""*income="";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;  	low income 	medium income 	high income
Min 	$12896 	$19400 	$32145
Max 	$18998 	$27419 	$78362
N 	9 	10 	10&lt;/PRE&gt;</description>
      <pubDate>Sat, 08 Feb 2020 20:00:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/SAS-code-to-create-cutpoints/m-p/623335#M8752</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2020-02-08T20:00:05Z</dc:date>
    </item>
    <item>
      <title>Re: SAS code to create cutpoints</title>
      <link>https://communities.sas.com/t5/SAS-Studio/SAS-code-to-create-cutpoints/m-p/629996#M8883</link>
      <description>Hi, you helped me sometime ago with the Sas code for cut points and thank you for that. However, the "data want' portion of the SAS code to create percentiile ranking(33.3 and 66.7) does not work. I would appreciate if you could help me with corrections. I tried several things to correct the error  but it still did not work. Thank you in advance.</description>
      <pubDate>Fri, 06 Mar 2020 02:47:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/SAS-code-to-create-cutpoints/m-p/629996#M8883</guid>
      <dc:creator>ak2011</dc:creator>
      <dc:date>2020-03-06T02:47:42Z</dc:date>
    </item>
  </channel>
</rss>

