<?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 format data on ranges? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-format-data-on-ranges/m-p/307552#M65893</link>
    <description>&lt;P&gt;Make it as a format dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; 
data have;
input subject $ bucket $ lower upper;
cards;
math bucket1 0 25
math bucket2 25 50
math bucket3 50 75
math bucket4 75 100
math bucket5 100 100
science bucket1 0 50
science bucket2 50 75
science bucket3 75 100
science bucket4 100 100
;
run;
 
data fmt;
 set have(rename=(lower=start upper=end bucket=label subject=fmtname));
run;
proc format cntlin=fmt;
run;

data want;
input name $ subject $ score bucket $;
new_bucket=putn(score,subject);
cards;
john math 24 bucket1
angela math 100 bucket5
alex science 50 bucket1
sophie science 75 bucket2
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 27 Oct 2016 03:16:02 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2016-10-27T03:16:02Z</dc:date>
    <item>
      <title>How to format data on ranges?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-format-data-on-ranges/m-p/307417#M65835</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a dataset here whose format I'd like to apply in another dataset. The student belongs on the specified bucket when her/ his score is less than/ equal to the upper, and greater than the lower, except for the bucket with the 100 as upper bound.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, the "have" dataset should not be manipulated to get the desired result.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is this possible?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data have;&lt;BR /&gt;input subject $ bucket $ lower upper;&lt;BR /&gt;cards;&lt;BR /&gt;math bucket1 0 25&lt;BR /&gt;math bucket2 25 50&lt;BR /&gt;math bucket3 50 75&lt;BR /&gt;math bucket4 75 100&lt;BR /&gt;math bucket5 100 100&lt;BR /&gt;science bucket1 0 50&lt;BR /&gt;science bucket2 50 75&lt;BR /&gt;science bucket3 75 100&lt;BR /&gt;science bucket4 100 100&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;BR /&gt;input name $ subject $ score bucket $;&lt;BR /&gt;cards;&lt;BR /&gt;john math 24 bucket1&lt;BR /&gt;angela math 100 bucket5&lt;BR /&gt;alex science 50 bucket1&lt;BR /&gt;sophie science 75 bucket2&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Oct 2016 14:33:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-format-data-on-ranges/m-p/307417#M65835</guid>
      <dc:creator>angeliquec</dc:creator>
      <dc:date>2016-10-26T14:33:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to format data on ranges?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-format-data-on-ranges/m-p/307429#M65839</link>
      <description>&lt;P&gt;We are talking here about merging data. &amp;nbsp;You could do it with formats, but it might not cover all your requirements. &amp;nbsp;Merging will:&lt;/P&gt;
&lt;PRE&gt;proc sql;
  create table WANT as
  select  A.NAME,
          A.SUBJECT,
          A.SCORE,
          B.BUCKET
  from    STUDENTS A
  left join HAVE B
  on      A.SUBJECT=B.SUBJECT
  and     B.LOWER &amp;lt;= A.SCORE &amp;lt;= B.UPPER;
quit;&lt;/PRE&gt;</description>
      <pubDate>Wed, 26 Oct 2016 14:44:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-format-data-on-ranges/m-p/307429#M65839</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-10-26T14:44:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to format data on ranges?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-format-data-on-ranges/m-p/307552#M65893</link>
      <description>&lt;P&gt;Make it as a format dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; 
data have;
input subject $ bucket $ lower upper;
cards;
math bucket1 0 25
math bucket2 25 50
math bucket3 50 75
math bucket4 75 100
math bucket5 100 100
science bucket1 0 50
science bucket2 50 75
science bucket3 75 100
science bucket4 100 100
;
run;
 
data fmt;
 set have(rename=(lower=start upper=end bucket=label subject=fmtname));
run;
proc format cntlin=fmt;
run;

data want;
input name $ subject $ score bucket $;
new_bucket=putn(score,subject);
cards;
john math 24 bucket1
angela math 100 bucket5
alex science 50 bucket1
sophie science 75 bucket2
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Oct 2016 03:16:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-format-data-on-ranges/m-p/307552#M65893</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-10-27T03:16:02Z</dc:date>
    </item>
  </channel>
</rss>

