<?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: Create tenure based on the first occurrence of a value within a group in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-tenure-based-on-the-first-occurrence-of-a-value-within-a/m-p/535040#M146862</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;, my apologies. I'm new to this forum and learning how to go about this.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How would you suggest I go about illustrating the situation? I've created a hypothetical data set which mirrors the issue I'm having due to confidentiality reasons.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your support and advice.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 12 Feb 2019 22:16:30 GMT</pubDate>
    <dc:creator>renanm</dc:creator>
    <dc:date>2019-02-12T22:16:30Z</dc:date>
    <item>
      <title>Create tenure based on the first occurrence of a value within a group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-tenure-based-on-the-first-occurrence-of-a-value-within-a/m-p/535021#M146854</link>
      <description>&lt;P&gt;Hello everyone,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried tackling the problem below multiple ways including using FIRST. and LAST. in BY-GROUP analysis, WHILE loops, but have not been unsuccessful so far. I'm running out of time and if anyone can provide some direction it'd be greatly appreciated.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's the situation:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a data set which is 'tenurized' based on the occurrence of a particular event. In this case, the event being a 'limit placement' which happens at a particular date defined as 'Limit_dt'. Therefore, as of the 'Limit_dt' the 'Tenure' field gets set to = 0 and increments by 1 until the last row for that particular customer group (ID). The data is sorted by ID, Limit_dt and Date.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;See below an illustration of what the data looks like as well as better explanation of each field. Field Tenure2 (highlighted in yellow) is what I'm attempting to tackle right now. Please ignore it for now.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Data Structure.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/27102i68128CF52128FA19/image-size/large?v=v2&amp;amp;px=999" role="button" title="Data Structure.PNG" alt="Data Structure.PNG" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Field description.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/27104i1AA7AD20084E8905/image-size/large?v=v2&amp;amp;px=999" role="button" title="Field description.PNG" alt="Field description.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Essentially, what I need to do here is 're-tenurize' this data set based on the FIRST occurrence Score_flag ='Y' within each customer group. To expand a bit on this, Score_flag = 'Y' when Score &amp;gt;= Score30 so this flag can basically jump back and forth between 'Y' and 'N' from month to month.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I need to do is create a field named 'Tenure2' which gets set to '0' at the FIRST occurrence (and ONLY the first occurrence for each ID) of Score_flag='Y' for a particular ID and increment by 1 from there until the last record/row for that customer (ID). The field 'Tenure2' in the illustration above exemplifies the values that this field should take.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hoping someone can direct me to a simple solution to this.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance for your support.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2019 21:39:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-tenure-based-on-the-first-occurrence-of-a-value-within-a/m-p/535021#M146854</guid>
      <dc:creator>renanm</dc:creator>
      <dc:date>2019-02-12T21:39:19Z</dc:date>
    </item>
    <item>
      <title>Re: Create tenure based on the first occurrence of a value within a group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-tenure-based-on-the-first-occurrence-of-a-value-within-a/m-p/535029#M146857</link>
      <description>&lt;P&gt;Like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WANT;
  retain TENURE2;
  set HAVE;
  by ID;
  if first.ID then TENURE2=.;
  if SCORE_FLAG='Y' then TENURE2=0;
  else TENURE2=TENURE2+1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2019 21:43:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-tenure-based-on-the-first-occurrence-of-a-value-within-a/m-p/535029#M146857</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-02-12T21:43:35Z</dc:date>
    </item>
    <item>
      <title>Re: Create tenure based on the first occurrence of a value within a group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-tenure-based-on-the-first-occurrence-of-a-value-within-a/m-p/535034#M146858</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;, thanks for your attempt at helping to solve this.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is similar to one of my previous attempts but unfortunately it doesn't solve the problem here.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here are some of the reasons why:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#1 - Whenever there are consecutive Score_flag = 'Y' month after month, the Tenure2 fields gets the value '0' again and again instead of incrementing by 1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#2 - Similarly, if Score_flag alternates between 'Y' and 'N' from month to month, every time it gets set to 'Y' again, the field Tenure2 gets re-set to '0' again.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;See illustrations of these situations below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example 1:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="EX1.PNG" style="width: 598px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/27105iFA70995DFCB7CBEC/image-size/large?v=v2&amp;amp;px=999" role="button" title="EX1.PNG" alt="EX1.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example 2:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="EX2.PNG" style="width: 578px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/27106i14C40372D67ABDAF/image-size/large?v=v2&amp;amp;px=999" role="button" title="EX2.PNG" alt="EX2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example 3:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="EX3.PNG" style="width: 577px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/27107iF7B1273A8D4A005A/image-size/large?v=v2&amp;amp;px=999" role="button" title="EX3.PNG" alt="EX3.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Essentially, Tenure2 needs to be set to '0' ONLY at the FIRST occurrence of&amp;nbsp;Score_flag = 'Y' within each customer group.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the missing piece I can't seem to figure out.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any additional help&amp;nbsp; is much appreciated.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks !&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2019 22:08:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-tenure-based-on-the-first-occurrence-of-a-value-within-a/m-p/535034#M146858</guid>
      <dc:creator>renanm</dc:creator>
      <dc:date>2019-02-12T22:08:32Z</dc:date>
    </item>
    <item>
      <title>Re: Create tenure based on the first occurrence of a value within a group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-tenure-based-on-the-first-occurrence-of-a-value-within-a/m-p/535037#M146860</link>
      <description>Don't post data as images, this means we can't test any code because we'd have to type out your data.</description>
      <pubDate>Tue, 12 Feb 2019 22:13:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-tenure-based-on-the-first-occurrence-of-a-value-within-a/m-p/535037#M146860</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-02-12T22:13:21Z</dc:date>
    </item>
    <item>
      <title>Re: Create tenure based on the first occurrence of a value within a group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-tenure-based-on-the-first-occurrence-of-a-value-within-a/m-p/535039#M146861</link>
      <description>&lt;P&gt;Add another flag. If this doesn't work, please post sample data following these instructions:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WANT;
  retain TENURE2;
  set HAVE;
  by ID;
  length first_flag $1.;
  retain first_flag;
  if first.ID then call missing(TENURE2, first_flag);;
  if score_flag='Y' and missing(first_flag) then do;
  tenure2=0;
first_flag='Y'; 
end;
  else TENURE2=TENURE2+1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/129176"&gt;@renanm&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;, thanks for your attempt at helping to solve this.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is similar to one of my previous attempts but unfortunately it doesn't solve the problem here.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here are some of the reasons why:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;#1 - Whenever there are consecutive Score_flag = 'Y' month after month, the Tenure2 fields gets the value '0' again and again instead of incrementing by 1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;#2 - Similarly, if Score_flag alternates between 'Y' and 'N' from month to month, every time it gets set to 'Y' again, the field Tenure2 gets re-set to '0' again.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See illustrations of these situations below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example 1:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="EX1.PNG" style="width: 598px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/27105iFA70995DFCB7CBEC/image-size/large?v=v2&amp;amp;px=999" role="button" title="EX1.PNG" alt="EX1.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example 2:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="EX2.PNG" style="width: 578px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/27106i14C40372D67ABDAF/image-size/large?v=v2&amp;amp;px=999" role="button" title="EX2.PNG" alt="EX2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example 3:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="EX3.PNG" style="width: 577px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/27107iF7B1273A8D4A005A/image-size/large?v=v2&amp;amp;px=999" role="button" title="EX3.PNG" alt="EX3.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Essentially, Tenure2 needs to be set to '0' ONLY at the FIRST occurrence of&amp;nbsp;Score_flag = 'Y' within each customer group.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is the missing piece I can't seem to figure out.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any additional help&amp;nbsp; is much appreciated.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks !&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2019 22:15:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-tenure-based-on-the-first-occurrence-of-a-value-within-a/m-p/535039#M146861</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-02-12T22:15:50Z</dc:date>
    </item>
    <item>
      <title>Re: Create tenure based on the first occurrence of a value within a group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-tenure-based-on-the-first-occurrence-of-a-value-within-a/m-p/535040#M146862</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;, my apologies. I'm new to this forum and learning how to go about this.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How would you suggest I go about illustrating the situation? I've created a hypothetical data set which mirrors the issue I'm having due to confidentiality reasons.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your support and advice.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2019 22:16:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-tenure-based-on-the-first-occurrence-of-a-value-within-a/m-p/535040#M146862</guid>
      <dc:creator>renanm</dc:creator>
      <dc:date>2019-02-12T22:16:30Z</dc:date>
    </item>
    <item>
      <title>Re: Create tenure based on the first occurrence of a value within a group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-tenure-based-on-the-first-occurrence-of-a-value-within-a/m-p/535046#M146865</link>
      <description>See my last answer to you.</description>
      <pubDate>Tue, 12 Feb 2019 22:33:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-tenure-based-on-the-first-occurrence-of-a-value-within-a/m-p/535046#M146865</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-02-12T22:33:33Z</dc:date>
    </item>
    <item>
      <title>Re: Create tenure based on the first occurrence of a value within a group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-tenure-based-on-the-first-occurrence-of-a-value-within-a/m-p/535049#M146867</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt;&amp;nbsp;Whenever there are consecutive Score_flag = 'Y' month after month, the Tenure2 fields gets the value '0'&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;This seems easy to solve. Have you even tried?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; WANT&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  &lt;SPAN class="token keyword"&gt;retain&lt;/SPAN&gt; TENURE2&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  &lt;SPAN class="token keyword"&gt;set&lt;/SPAN&gt; HAVE&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  &lt;SPAN class="token statement"&gt;by&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;ID&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  &lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;first&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;ID&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;then&lt;/SPAN&gt; TENURE2&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  &lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; SCORE_FLAG&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'Y'&lt;/SPAN&gt; &amp;amp; TENURE2&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;. &lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;then&lt;/SPAN&gt; TENURE2&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;-1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  TENURE2&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;TENURE2&lt;SPAN class="token operator"&gt;+&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And yes, as&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;said, posting images as data prevents us from running code on actual data (unless we do the work for you and create actual data, but why would we do your work?)&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2019 22:42:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-tenure-based-on-the-first-occurrence-of-a-value-within-a/m-p/535049#M146867</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-02-12T22:42:02Z</dc:date>
    </item>
    <item>
      <title>Re: Create tenure based on the first occurrence of a value within a group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-tenure-based-on-the-first-occurrence-of-a-value-within-a/m-p/535056#M146871</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;for sharing these instructions and guidelines. I'll ensure to follow them the next time around.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2019 23:08:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-tenure-based-on-the-first-occurrence-of-a-value-within-a/m-p/535056#M146871</guid>
      <dc:creator>renanm</dc:creator>
      <dc:date>2019-02-12T23:08:55Z</dc:date>
    </item>
    <item>
      <title>Re: Create tenure based on the first occurrence of a value within a group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-tenure-based-on-the-first-occurrence-of-a-value-within-a/m-p/535057#M146872</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;. This seems to solve it and quite interesting the way you approached this. Helped me to learn a lot. Much appreciated.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2019 23:10:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-tenure-based-on-the-first-occurrence-of-a-value-within-a/m-p/535057#M146872</guid>
      <dc:creator>renanm</dc:creator>
      <dc:date>2019-02-12T23:10:24Z</dc:date>
    </item>
    <item>
      <title>Re: Create tenure based on the first occurrence of a value within a group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-tenure-based-on-the-first-occurrence-of-a-value-within-a/m-p/535058#M146873</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again for your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As mentioned in my response to Reeza above, I'm new to this forum and did not know posting images was not acceptable. I thought that would be a good way to clearly illustrate the situation I was dealing with and clearly demonstrate it to the contributors of the forum.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It won't happen again. I'll follow the guidelines shared by Reeza next time.&amp;nbsp;That wasn't meant for you to do my work for me, I simply&lt;BR /&gt;didn't know better.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And to answer your other question of whether or not I have even tried, the answer is YES. I have tried multiple times and searched for different solutions. Unfortunately, as you can tell, I'm learning and wasn't able to find a solution. I'll get there and hopefully one day be&lt;BR /&gt;able to help others with similar situations.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for sharing another alternative to the problem.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2019 23:14:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-tenure-based-on-the-first-occurrence-of-a-value-within-a/m-p/535058#M146873</guid>
      <dc:creator>renanm</dc:creator>
      <dc:date>2019-02-12T23:14:26Z</dc:date>
    </item>
    <item>
      <title>Re: Create tenure based on the first occurrence of a value within a group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-tenure-based-on-the-first-occurrence-of-a-value-within-a/m-p/535061#M146876</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/129176"&gt;@renanm&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks again for your help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As mentioned in my response to Reeza above, I'm new to this forum and did not know posting images was not acceptable. I thought that would be a good way to clearly illustrate the situation I was dealing with and clearly demonstrate it to the contributors of the forum.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It isn't that images are "not acceptable" but that they can be misleading. We will get a number of posts each week often involving dates but sometimes other values, that appear to be one thing, SAS date value or numeric and are actually character values in the users data. Or "dates" that look like 20190215 that are actually simple numbers and do not have the proper values for use with date functions and formats.&lt;/P&gt;
&lt;P&gt;Also testing code without actual values is difficult and too time consuming for most of us to type. There is a SAS macro program at&amp;nbsp; &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We also like to see the code that you tried because sometimes all it takes is tweak to get it working. It is not uncommon for someone coming from a different programming or scripting language to use something that may be valid in SAS but means something different than the other language. The fun thing with this can be the rules SAS uses.&lt;/P&gt;
&lt;P&gt;A moderately common issue is comparing values:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if x = 3 or 4 then do &amp;lt;some code&amp;gt;; for example. Does NOT throw an error but will always do the code represented by &amp;lt;some code&amp;gt;&lt;/P&gt;
&lt;P&gt;Reason: the value 4, being non-zero is treated as true all by itself and x is only compared to 3 because there was no instruction to compare x to 4. So the code could be fixed by either&lt;/P&gt;
&lt;P&gt;if x=3 or x=4 then do &amp;lt;some code&amp;gt;.&lt;/P&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;P&gt;if x in (3,4) then do &amp;lt;some code&amp;gt;.&lt;/P&gt;
&lt;P&gt;So if you had posted code with something like the first If we could relatively quickly point that out. Code and log entries should be pasted into code boxes opened with either the {I} or "running man" icon to preserve formatting. The main message windows will reformat text removing lots of white space and that often makes data step code fail in one way or another. Error messages from the log also often have diagnostic characters like an _ where the error is found. If you paste one of those into the main message window the _ character usually ends up under something not related to the error.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2019 23:34:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-tenure-based-on-the-first-occurrence-of-a-value-within-a/m-p/535061#M146876</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-02-12T23:34:55Z</dc:date>
    </item>
    <item>
      <title>Re: Create tenure based on the first occurrence of a value within a group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-tenure-based-on-the-first-occurrence-of-a-value-within-a/m-p/535066#M146880</link>
      <description>&lt;P&gt;Very helpful context and guidelines. Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Feb 2019 00:04:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-tenure-based-on-the-first-occurrence-of-a-value-within-a/m-p/535066#M146880</guid>
      <dc:creator>renanm</dc:creator>
      <dc:date>2019-02-13T00:04:52Z</dc:date>
    </item>
  </channel>
</rss>

