<?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 How to separate into two data sets by conditionally looping through variables? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-separate-into-two-data-sets-by-conditionally-looping/m-p/463114#M117932</link>
    <description>&lt;P&gt;I need to separate a variable into small groups, for example, besides missing and 0, keep every 100 as a small group, how to write a macro or do loop to do this?&lt;/P&gt;&lt;P&gt;/*data bucket1;*/&lt;/P&gt;&lt;P&gt;/*set rf.bucket1;*/&lt;/P&gt;&lt;P&gt;/*if t_amt_pd_inst_trd=. then group=1;*/&lt;/P&gt;&lt;P&gt;/*else if t_amt_pd_inst_trd=0 then group=2;*/&lt;/P&gt;&lt;P&gt;/*else if t_amt_pd_inst_trd&amp;gt;=1 and t_amt_pd_inst_trd&amp;lt;=100 then group=3;*/&lt;/P&gt;&lt;P&gt;/*else if t_amt_pd_inst_trd&amp;gt;=101 and t_amt_pd_inst_trd&amp;lt;=200 then group=4;*/&lt;/P&gt;&lt;P&gt;/*else if t_amt_pd_inst_trd&amp;gt;=201 and t_amt_pd_inst_trd&amp;lt;=300 then group=5;*/&lt;/P&gt;&lt;P&gt;/*else if t_amt_pd_inst_trd&amp;gt;=301 and t_amt_pd_inst_trd&amp;lt;=400 then group=6;*/&lt;/P&gt;&lt;P&gt;/*else if t_amt_pd_inst_trd&amp;gt;=401 and t_amt_pd_inst_trd&amp;lt;=500 then group=7;*/&lt;/P&gt;&lt;P&gt;/*else if t_amt_pd_inst_trd&amp;gt;=501 and t_amt_pd_inst_trd&amp;lt;=600 then group=8;*/&lt;/P&gt;&lt;P&gt;/*else if t_amt_pd_inst_trd&amp;gt;=601 and t_amt_pd_inst_trd&amp;lt;=700 then group=9;*/&lt;/P&gt;&lt;P&gt;/*else if t_amt_pd_inst_trd&amp;gt;=701 and t_amt_pd_inst_trd&amp;lt;=800 then group=10;*/&lt;/P&gt;&lt;P&gt;......&lt;/P&gt;&lt;P&gt;......&lt;/P&gt;&lt;P&gt;......&lt;/P&gt;</description>
    <pubDate>Thu, 17 May 2018 19:29:00 GMT</pubDate>
    <dc:creator>garfield83</dc:creator>
    <dc:date>2018-05-17T19:29:00Z</dc:date>
    <item>
      <title>How to separate into two data sets by conditionally looping through variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-separate-into-two-data-sets-by-conditionally-looping/m-p/463114#M117932</link>
      <description>&lt;P&gt;I need to separate a variable into small groups, for example, besides missing and 0, keep every 100 as a small group, how to write a macro or do loop to do this?&lt;/P&gt;&lt;P&gt;/*data bucket1;*/&lt;/P&gt;&lt;P&gt;/*set rf.bucket1;*/&lt;/P&gt;&lt;P&gt;/*if t_amt_pd_inst_trd=. then group=1;*/&lt;/P&gt;&lt;P&gt;/*else if t_amt_pd_inst_trd=0 then group=2;*/&lt;/P&gt;&lt;P&gt;/*else if t_amt_pd_inst_trd&amp;gt;=1 and t_amt_pd_inst_trd&amp;lt;=100 then group=3;*/&lt;/P&gt;&lt;P&gt;/*else if t_amt_pd_inst_trd&amp;gt;=101 and t_amt_pd_inst_trd&amp;lt;=200 then group=4;*/&lt;/P&gt;&lt;P&gt;/*else if t_amt_pd_inst_trd&amp;gt;=201 and t_amt_pd_inst_trd&amp;lt;=300 then group=5;*/&lt;/P&gt;&lt;P&gt;/*else if t_amt_pd_inst_trd&amp;gt;=301 and t_amt_pd_inst_trd&amp;lt;=400 then group=6;*/&lt;/P&gt;&lt;P&gt;/*else if t_amt_pd_inst_trd&amp;gt;=401 and t_amt_pd_inst_trd&amp;lt;=500 then group=7;*/&lt;/P&gt;&lt;P&gt;/*else if t_amt_pd_inst_trd&amp;gt;=501 and t_amt_pd_inst_trd&amp;lt;=600 then group=8;*/&lt;/P&gt;&lt;P&gt;/*else if t_amt_pd_inst_trd&amp;gt;=601 and t_amt_pd_inst_trd&amp;lt;=700 then group=9;*/&lt;/P&gt;&lt;P&gt;/*else if t_amt_pd_inst_trd&amp;gt;=701 and t_amt_pd_inst_trd&amp;lt;=800 then group=10;*/&lt;/P&gt;&lt;P&gt;......&lt;/P&gt;&lt;P&gt;......&lt;/P&gt;&lt;P&gt;......&lt;/P&gt;</description>
      <pubDate>Thu, 17 May 2018 19:29:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-separate-into-two-data-sets-by-conditionally-looping/m-p/463114#M117932</guid>
      <dc:creator>garfield83</dc:creator>
      <dc:date>2018-05-17T19:29:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to separate into two data sets by conditionally looping through variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-separate-into-two-data-sets-by-conditionally-looping/m-p/463123#M117935</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
n=.;
output;
do n=0 to 1000;
output;
end;
run;

data want;
set have;
if  missing(n)  then do; group=1;output;end;
else if n in (0,1) then do;group+1;output;end;
else if mod(n,100)=0 then do;
output;group+1;end;
else output;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 May 2018 19:54:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-separate-into-two-data-sets-by-conditionally-looping/m-p/463123#M117935</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-05-17T19:54:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to separate into two data sets by conditionally looping through variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-separate-into-two-data-sets-by-conditionally-looping/m-p/463137#M117938</link>
      <description>&lt;P&gt;Your first few categories have to be written out (similar to what you did).&amp;nbsp; But the rest can be collapsed into a single statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if t_amt_pd_inst_trd=. then group=1;&lt;/P&gt;
&lt;P&gt;else if t_amt_pd_inst_trd=0 then group=2;&lt;/P&gt;
&lt;P&gt;else if t_amt_pd_inst_trd&amp;gt;=1 then group =&amp;nbsp;3 + int((t_amt_pd_inst_trd-1)/100);&lt;/P&gt;</description>
      <pubDate>Thu, 17 May 2018 20:12:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-separate-into-two-data-sets-by-conditionally-looping/m-p/463137#M117938</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-05-17T20:12:42Z</dc:date>
    </item>
  </channel>
</rss>

