<?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: Base sas coding in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Base-sas-coding/m-p/524095#M4748</link>
    <description>&lt;P&gt;Your output table doesn't make sense.&lt;/P&gt;</description>
    <pubDate>Wed, 02 Jan 2019 14:36:56 GMT</pubDate>
    <dc:creator>cosmid</dc:creator>
    <dc:date>2019-01-02T14:36:56Z</dc:date>
    <item>
      <title>Base sas coding</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Base-sas-coding/m-p/524086#M4746</link>
      <description>&lt;P&gt;Help me in getting the below output&lt;/P&gt;&lt;P&gt;Table 1&lt;/P&gt;&lt;P&gt;Id&amp;nbsp; &amp;nbsp;Per&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp;10&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp;20&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp;60&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp;90&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Table 2&lt;/P&gt;&lt;P&gt;Id range1 range2&amp;nbsp; Rating&lt;/P&gt;&lt;P&gt;1&amp;nbsp; 10&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 20&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;1&amp;nbsp; 21&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 40&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&lt;/P&gt;&lt;P&gt;1&amp;nbsp; 41&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 60&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3&lt;/P&gt;&lt;P&gt;2&amp;nbsp; 10&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 20&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;2&amp;nbsp; 21&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 60&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&lt;/P&gt;&lt;P&gt;2&amp;nbsp; 61&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 90&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Output&lt;/P&gt;&lt;P&gt;Id&amp;nbsp; &amp;nbsp;Per&amp;nbsp; rating&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp;10&amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp;20&amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp;60&amp;nbsp; &amp;nbsp; 2&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp;90&amp;nbsp; &amp;nbsp; 3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Similary I have many IDs and their ranges and rating&lt;/P&gt;&lt;P&gt;I need help in coding this with out hardcoding&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jan 2019 13:51:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Base-sas-coding/m-p/524086#M4746</guid>
      <dc:creator>molla</dc:creator>
      <dc:date>2019-01-02T13:51:21Z</dc:date>
    </item>
    <item>
      <title>Re: Base sas coding</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Base-sas-coding/m-p/524088#M4747</link>
      <description>&lt;P&gt;What did you try? Can you explain in words what the two input tables are?&amp;nbsp; In particular the ID variable seems confusing to me.&amp;nbsp; At first I thought it was just identifying different subjects in the first table, but then it appears to be important in the second table also. Perhaps it is more of an id of which rating system you want to use?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also how do you get the last two results?&amp;nbsp; For ID=2 and PER=60 why is the result 2 and not 3?&amp;nbsp; For ID=1 and PER=90 why is the result 3 and not missing?&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jan 2019 14:22:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Base-sas-coding/m-p/524088#M4747</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-01-02T14:22:52Z</dc:date>
    </item>
    <item>
      <title>Re: Base sas coding</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Base-sas-coding/m-p/524095#M4748</link>
      <description>&lt;P&gt;Your output table doesn't make sense.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jan 2019 14:36:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Base-sas-coding/m-p/524095#M4748</guid>
      <dc:creator>cosmid</dc:creator>
      <dc:date>2019-01-02T14:36:56Z</dc:date>
    </item>
    <item>
      <title>Re: Base sas coding</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Base-sas-coding/m-p/524098#M4749</link>
      <description>&lt;P&gt;If Id in both tables matches we need to check the per column in the table1&amp;nbsp;&lt;/P&gt;&lt;P&gt;With the range1&amp;nbsp; and range2 ,accor accord we need to give the rating as defined in table 2&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jan 2019 14:45:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Base-sas-coding/m-p/524098#M4749</guid>
      <dc:creator>molla</dc:creator>
      <dc:date>2019-01-02T14:45:24Z</dc:date>
    </item>
    <item>
      <title>Re: Base sas coding</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Base-sas-coding/m-p/524099#M4750</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/116130"&gt;@molla&lt;/a&gt;&amp;nbsp;Like others pointed out, Your output sample isn't clear, that leads us to assumptions.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp;90&amp;nbsp; &amp;nbsp; &lt;FONT color="#FF0000"&gt;3&amp;nbsp; /*this should be missing*/&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
input Id   Per;
cards;
1     10
1     20
2     60
1     90
;

data two;
input Id range1 range2  Rating;
cards;
1  10          20          1
1  21          40          2
1  41          60          3
2  10          20          1
2  21          60          2
2  61          90          3
;

proc sql;
create table want as
select  a.*,b.rating
from one a left join two b
on a.id=b.id and (a.per=b.range1 or a.per=b.range2)
order by id,per;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 02 Jan 2019 14:47:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Base-sas-coding/m-p/524099#M4750</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-01-02T14:47:12Z</dc:date>
    </item>
    <item>
      <title>Re: Base sas coding</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Base-sas-coding/m-p/524102#M4751</link>
      <description>&lt;P&gt;Step 1:&amp;nbsp; create a format based on TABLE2:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data make_format;&lt;/P&gt;
&lt;P&gt;set table2;&lt;/P&gt;
&lt;P&gt;fmtname='$idrange';&lt;/P&gt;
&lt;P&gt;start = put(id, z3.) || put(range1, z3.);&lt;/P&gt;
&lt;P&gt;end = put(id, z3.) || put(range2, z3.);&lt;/P&gt;
&lt;P&gt;keep fmtname start end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The use of the z3 format is assuming that your ID values and range values are limited to no more than 3 digits. And the solution is assuming that ID is a numeric variable.&amp;nbsp; If the real data is different, that can still be programmed with small changes.&amp;nbsp; But since the post doesn't mention anything about the characteristics of the variables, I had to start somewhere by making some assumptions.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc format cntlin=make_format;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Step 2:&amp;nbsp; Use the format to assign RATING:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set table1;&lt;/P&gt;
&lt;P&gt;rating = input( &lt;FONT color="#FF0000"&gt;put(&lt;/FONT&gt; &lt;FONT color="#0000FF"&gt;put(id, z3.) || put(per, z3.)&lt;/FONT&gt; &lt;FONT color="#FF0000"&gt;, $idrange.)&lt;/FONT&gt;, 3.);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jan 2019 14:52:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Base-sas-coding/m-p/524102#M4751</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-01-02T14:52:57Z</dc:date>
    </item>
    <item>
      <title>Re: Base sas coding</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Base-sas-coding/m-p/524107#M4752</link>
      <description>&lt;P&gt;Yes it should be missing,it's my mistake,&lt;/P&gt;&lt;P&gt;And the per value will not be the the boundaries of the range values,&lt;/P&gt;&lt;P&gt;It may be in between the range1 and range2&lt;/P&gt;&lt;P&gt;Like 23,44.4...in this cases also it should the proper rating&lt;/P&gt;&lt;P&gt;The ids also increase up to 10 and the corresponding per and rating.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;@&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jan 2019 15:04:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Base-sas-coding/m-p/524107#M4752</guid>
      <dc:creator>molla</dc:creator>
      <dc:date>2019-01-02T15:04:49Z</dc:date>
    </item>
    <item>
      <title>Re: Base sas coding</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Base-sas-coding/m-p/524110#M4753</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does the following help?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have1;
   input id per;
   datalines;
1 10
1 20
2 60
1 90
;

data have2;
   input id range1 range2 rating;
   datalines;
1 10 20 1
1 21 40 2
1 41 60 3
2 10 20 1
2 20 60 2
2 61 90 3
;

/* use sql to lookup data */
proc sql noprint;
   create table
      want as
   select
      have1.*
      ,rating
   from
      have1 h1
   left join
      have2 h2
   on
          h1.id eq h2.id
      and per between range1 and range2
   ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Amir.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jan 2019 15:17:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Base-sas-coding/m-p/524110#M4753</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2019-01-02T15:17:35Z</dc:date>
    </item>
    <item>
      <title>Re: Base sas coding</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Base-sas-coding/m-p/524111#M4754</link>
      <description>&lt;P&gt;Ok just a slight tweak&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data one;
input Id   Per;
cards;
1     10
1     20
2     60
1     90
;

data two;
input Id range1 range2  Rating;
cards;
1  10          20          1
1  21          40          2
1  41          60          3
2  10          20          1
2  21          60          2
2  61          90          3
;

proc sql;
create table want as
select  a.*, rating
from one a left join two b
on a.id=b.id and (b.range1&amp;lt;=a.per&amp;lt;=b.range2)
group by a.id,per
order by id,per;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 02 Jan 2019 15:19:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Base-sas-coding/m-p/524111#M4754</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-01-02T15:19:14Z</dc:date>
    </item>
  </channel>
</rss>

