<?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: Data stratification with alternative classes in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Data-stratification-with-alternative-classes/m-p/559949#M156439</link>
    <description>&lt;P&gt;Please post some example data in usable form (as you have already been shown in the solution to &lt;A href="https://communities.sas.com/t5/SAS-Programming/Referring-to-fixed-constraints-and-calculated-values-to-compute/m-p/554589#M154288" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/SAS-Programming/Referring-to-fixed-constraints-and-calculated-values-to-compute/m-p/554589&lt;/A&gt;), and what you expect to get out of it.&lt;/P&gt;</description>
    <pubDate>Sun, 19 May 2019 12:33:34 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2019-05-19T12:33:34Z</dc:date>
    <item>
      <title>Data stratification with alternative classes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-stratification-with-alternative-classes/m-p/559948#M156438</link>
      <description>&lt;P&gt;Dear community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a business data set that needs to be stratified based on business characteristics, namely&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;STATE (location),&lt;/LI&gt;&lt;LI&gt;BTYPE (business type) and&lt;/LI&gt;&lt;LI&gt;BSIZE (business size class).&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Each stratum shall include at least 'N' observations. The figure is fixed annually.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Variables STATE and BTYPE I already have, but BSIZE needs to be formed from variable SALES (annual sales). Each business has a unique register number (BREG).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Business size classes (based on sales) have been selected with following criteria (GE means &amp;gt;=, LT means &amp;lt;):&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data CLASSES;
 input CLASS LOWLIMITGE UPLIMITLT;
cards;&lt;/CODE&gt;&lt;BR /&gt;&lt;BR /&gt;1 0 2000&lt;BR /&gt;2 2000 4000&lt;BR /&gt;3 4000 8000&lt;BR /&gt;4 8000 15000&lt;BR /&gt;5 15000 25000&lt;BR /&gt;6 25000 50000&lt;BR /&gt;7 50000 100000&lt;BR /&gt;8 100000 250000&lt;BR /&gt;9 250000 500000&lt;BR /&gt;10 500000 750000&lt;BR /&gt;11 750000 1000000&lt;BR /&gt;12 1000000 1500000&lt;BR /&gt;13 1500000 3000000&lt;BR /&gt;14 3000000 .&lt;BR /&gt;&lt;BR /&gt;run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Business size classes have been regulated to following strata:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Class 2 and 3: Superior or equal to 2000 and strictly inferior to 8000.&lt;/P&gt;&lt;P&gt;Class 4 and 5: Superior or equal to 8000 and strictly inferior to 25000.&lt;/P&gt;&lt;P&gt;Class 6 and 7:&amp;nbsp;Superior or equal to 25000 and strictly inferior to 100000.&lt;/P&gt;&lt;P&gt;Class 8 and 9:&amp;nbsp;Superior or equal to 100000 and strictly inferior to 500000.&lt;/P&gt;&lt;P&gt;Class 10 and 11:&amp;nbsp;Superior or equal to 500000 and strictly inferior to 1000000.&lt;/P&gt;&lt;P&gt;Class 12-14:&amp;nbsp;Superior or equal to 1000000.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since this does not always work due to limited amount of business falling into these classes, there are three alternative classes available:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Class 3 and 4:&amp;nbsp;Superior or equal to 4000 and strictly inferior to 15000.&lt;/P&gt;&lt;P&gt;Class 3-5:&amp;nbsp;Superior or equal to 4000 and strictly inferior to 25000.&lt;/P&gt;&lt;P&gt;Class 10-14:&amp;nbsp;Superior or equal to 500000.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm looking for a way to formalize this into SAS code so that business would be stratified into regulated classes so that given criteria (minimum N observations in stratum) is met.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help me out.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example data. In reality I have 10000's of lines and target is to have around hundred observations for each stratum.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data BUSINESS;
 input BREG SALES STATE BTYPE;
cards;

82586	34000	1	A
33371	14000	2	B
53592	37000	3	C
7462	73000	4	D
88541	16000	1	A
77074	207000	2	B
33588	484000	3	C
86921	356000	4	D
41686	720000	1	A
11111	597000	2	B
59248	85000	3	C
58803	439000	4	D
57636	660000	1	A
97406	103000	2	B
98838	539000	3	C
36371	2000	4	D
75789	624000	1	A
81511	509000	2	B
4898	14000	3	C
98233	6000	4	D
60726	86000	1	A
62752	63000	2	B
47901	49000	3	C
62261	50000	4	D
25577	23000	1	A
47730	98000	2	B
54319	88000	3	C
16655	26000	4	D
87014	60000	1	A
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 20 May 2019 04:52:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-stratification-with-alternative-classes/m-p/559948#M156438</guid>
      <dc:creator>1Alina</dc:creator>
      <dc:date>2019-05-20T04:52:24Z</dc:date>
    </item>
    <item>
      <title>Re: Data stratification with alternative classes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-stratification-with-alternative-classes/m-p/559949#M156439</link>
      <description>&lt;P&gt;Please post some example data in usable form (as you have already been shown in the solution to &lt;A href="https://communities.sas.com/t5/SAS-Programming/Referring-to-fixed-constraints-and-calculated-values-to-compute/m-p/554589#M154288" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/SAS-Programming/Referring-to-fixed-constraints-and-calculated-values-to-compute/m-p/554589&lt;/A&gt;), and what you expect to get out of it.&lt;/P&gt;</description>
      <pubDate>Sun, 19 May 2019 12:33:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-stratification-with-alternative-classes/m-p/559949#M156439</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-05-19T12:33:34Z</dc:date>
    </item>
    <item>
      <title>Re: Data stratification with alternative classes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-stratification-with-alternative-classes/m-p/560243#M156615</link>
      <description>&lt;P&gt;I have added sample data and supplemented the post with additional information.&lt;/P&gt;</description>
      <pubDate>Mon, 20 May 2019 18:20:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-stratification-with-alternative-classes/m-p/560243#M156615</guid>
      <dc:creator>1Alina</dc:creator>
      <dc:date>2019-05-20T18:20:16Z</dc:date>
    </item>
    <item>
      <title>Re: Data stratification with alternative classes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-stratification-with-alternative-classes/m-p/560392#M156694</link>
      <description>&lt;P&gt;Such classification is usually handled best with formats:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data BUSINESS;
infile datalines dsd dlm='09'x;
input BREG $ SALES STATE BTYPE $;
datalines;
82586	34000	1	A
33371	14000	2	B
53592	37000	3	C
7462	73000	4	D
88541	16000	1	A
77074	207000	2	B
33588	484000	3	C
86921	356000	4	D
41686	720000	1	A
11111	597000	2	B
59248	85000	3	C
58803	439000	4	D
57636	660000	1	A
97406	103000	2	B
98838	539000	3	C
36371	2000	4	D
75789	624000	1	A
81511	509000	2	B
4898	14000	3	C
98233	6000	4	D
60726	86000	1	A
62752	63000	2	B
47901	49000	3	C
62261	50000	4	D
25577	23000	1	A
47730	98000	2	B
54319	88000	3	C
16655	26000	4	D
87014	60000	1	A
;

proc format;
value strat
  0-&amp;lt;2000 = "1"
  2000-&amp;lt;4000 = "2"
  4000-&amp;lt;8000 = "3"
  8000-&amp;lt;15000 = "4"
  15000-&amp;lt;25000 = "5"
  25000-&amp;lt;50000 = "6"
  50000-&amp;lt;100000 = "7"
  100000-&amp;lt;250000 = "8"
  250000-&amp;lt;500000 = "9"
  500000-&amp;lt;750000 = "10"
  750000-&amp;lt;1000000 = "11"
  1000000-&amp;lt;1500000 = "12"
  1500000-&amp;lt;3000000 = "13"
  3000000-high = "14"
;
run;

data want;
set business;
strat = put(sales,strat.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can now run proc freq:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=want;
tables strat;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to decide if you need to adapt your format.&lt;/P&gt;</description>
      <pubDate>Tue, 21 May 2019 08:20:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-stratification-with-alternative-classes/m-p/560392#M156694</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-05-21T08:20:10Z</dc:date>
    </item>
  </channel>
</rss>

