<?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: Creating a new variable based on two others in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-variable-based-on-two-others/m-p/755723#M238533</link>
    <description>&lt;P&gt;Use proc rank:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc rank data=have out=want;
by id;
var date;
ranks day;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 21 Jul 2021 18:36:05 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2021-07-21T18:36:05Z</dc:date>
    <item>
      <title>Creating a new variable based on two others</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-variable-based-on-two-others/m-p/755717#M238531</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have some data, below is a test sample of what I have .&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID $ date:mmddyy10. value;
format date mmddyy10.;
datalines;
1 12/01/2020 5
1 12/02/2020 6
1 12/03/2020 7
2 12/01/2020 10
2 12/02/2020 8
2 12/03/2020 9
3 12/01/2020 2
3 12/02/2020 2
3 12/03/2020 2
4 12/01/2020 5
4 12/02/2020 8
4 12/03/2020 6 
5 12/01/2020 2
5 12/02/2020 5
5 12/03/2020 4 
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Essentially what I want to do is per ID number, I want to create a new variable called day and have it number from the first date to the last date as day 1, 2, 3, etc. Below is an example of what I would want to do.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID $ date:mmddyy10. value day;
format date mmddyy10.;
datalines;
1 12/01/2020 5 1
1 12/02/2020 6 2
1 12/03/2020 7 3
2 12/01/2020 10 1 
2 12/02/2020 8 2
2 12/03/2020 9 3 
3 12/01/2020 2 1 
3 12/02/2020 2 2
3 12/03/2020 2 3
4 12/01/2020 5 1 
4 12/02/2020 8 2
4 12/03/2020 6 3
5 12/01/2020 2 1
5 12/02/2020 5 2
5 12/03/2020 4 3
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I tried to originally create a do loop with first.date and last.date but I wasn't sure how to incorporate the ID number as well, and when I tried to I kept getting errors&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face_with_sweat:"&gt;😅&lt;/span&gt;. Any ideas on how to create this? Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jul 2021 18:11:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-variable-based-on-two-others/m-p/755717#M238531</guid>
      <dc:creator>mitrakos</dc:creator>
      <dc:date>2021-07-21T18:11:27Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a new variable based on two others</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-variable-based-on-two-others/m-p/755723#M238533</link>
      <description>&lt;P&gt;Use proc rank:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc rank data=have out=want;
by id;
var date;
ranks day;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 21 Jul 2021 18:36:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-variable-based-on-two-others/m-p/755723#M238533</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2021-07-21T18:36:05Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a new variable based on two others</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-variable-based-on-two-others/m-p/755730#M238535</link>
      <description>Turns out I was making a simple problem into a very complicated solution. Thank you!!</description>
      <pubDate>Wed, 21 Jul 2021 19:05:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-variable-based-on-two-others/m-p/755730#M238535</guid>
      <dc:creator>mitrakos</dc:creator>
      <dc:date>2021-07-21T19:05:51Z</dc:date>
    </item>
  </channel>
</rss>

