<?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 serial number by CustID with related to IND column in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/create-serial-number-by-CustID-with-related-to-IND-column/m-p/955443#M373138</link>
    <description>&lt;P&gt;What you gotta do if you have serial number 1s&amp;nbsp; one by one , like this :&lt;/P&gt;
&lt;P&gt;0&lt;/P&gt;
&lt;P&gt;1&lt;/P&gt;
&lt;P&gt;1&lt;/P&gt;
&lt;P&gt;1&lt;/P&gt;
&lt;P&gt;0&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input CustID mon Ind;
cards;
111 1 0
111 2 0
111 3 1
111 4 0
111 5 0
111 6 0
111 7 0
111 8 0
111 9 1
111 10 0
111 11 0
111 12 0
222 1 0
222 2 0
222 3 0
222 4 0
222 5 0
222 6 0
222 7 0
222 8 0
222 9 0
222 10 0
222 11 0
222 12 0
333 1 0
333 2 1
333 3 0
;
Run;
data want;
 set have;
 by CustID;
 if first.CustID then serial=1;
 if not first.CustID and Ind then serial+1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 08 Jan 2025 02:27:05 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2025-01-08T02:27:05Z</dc:date>
    <item>
      <title>create serial number by CustID with related to IND column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-serial-number-by-CustID-with-related-to-IND-column/m-p/955299#M373099</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;for each customer there are until 12 rows (each row represent account balance in end of&amp;nbsp; &amp;nbsp;month).&lt;/P&gt;
&lt;P&gt;There is a column called Ind that get value 1 or 0 (1 means that there is a change in contract number in this month).&lt;/P&gt;
&lt;P&gt;I want to create a new varaible caled serial that create a serial numbers for each customerID by the following rule:&lt;/P&gt;
&lt;P&gt;If there is a change (means that Ind=1) then&amp;nbsp; go up by one in the serial number until there is another value 1 in field Ind.&lt;/P&gt;
&lt;P&gt;what is the way to do it please?&lt;/P&gt;
&lt;P&gt;I also show the want data set&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input CustID mon Ind;
cards;
111 1 0
111 2 0
111 3 1
111 4 0
111 5 0
111 6 0
111 7 0
111 8 0
111 9 1
111 10 0
111 11 0
111 12 0
222 1 0
222 2 0
222 3 0
222 4 0
222 5 0
222 6 0
222 7 0
222 8 0
222 9 0
222 10 0
222 11 0
222 12 0
333 1 0
333 2 0
333 3 0
;
Run;

data want;
input CustID mon Ind serial;
cards;
111 1 0 1
111 2 0 1
111 3 1 2
111 4 0 2
111 5 0 2
111 6 0 2
111 7 0 2
111 8 0 2
111 9 1 3
111 10 0 3
111 11 0 3
111 12 0 3
222 1 0 1
222 2 0 1
222 3 0 1
222 4 0 1
222 5 0 1
222 6 0 1
222 7 0 1
222 8 0 1
222 9 0 1
222 10 0 1
222 11 0 1
222 12 0 1
333 1 0 1
333 2 1 2
333 3 0 2
;
Run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Jan 2025 11:28:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-serial-number-by-CustID-with-related-to-IND-column/m-p/955299#M373099</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2025-01-07T11:28:52Z</dc:date>
    </item>
    <item>
      <title>Re: create serial number by CustID with related to IND column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-serial-number-by-CustID-with-related-to-IND-column/m-p/955300#M373100</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set have;
   by CustID;
   if first.CustID then serial = 1;
   if Ind then serial + 1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Jan 2025 11:33:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-serial-number-by-CustID-with-related-to-IND-column/m-p/955300#M373100</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2025-01-07T11:33:54Z</dc:date>
    </item>
    <item>
      <title>Re: create serial number by CustID with related to IND column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-serial-number-by-CustID-with-related-to-IND-column/m-p/955443#M373138</link>
      <description>&lt;P&gt;What you gotta do if you have serial number 1s&amp;nbsp; one by one , like this :&lt;/P&gt;
&lt;P&gt;0&lt;/P&gt;
&lt;P&gt;1&lt;/P&gt;
&lt;P&gt;1&lt;/P&gt;
&lt;P&gt;1&lt;/P&gt;
&lt;P&gt;0&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input CustID mon Ind;
cards;
111 1 0
111 2 0
111 3 1
111 4 0
111 5 0
111 6 0
111 7 0
111 8 0
111 9 1
111 10 0
111 11 0
111 12 0
222 1 0
222 2 0
222 3 0
222 4 0
222 5 0
222 6 0
222 7 0
222 8 0
222 9 0
222 10 0
222 11 0
222 12 0
333 1 0
333 2 1
333 3 0
;
Run;
data want;
 set have;
 by CustID;
 if first.CustID then serial=1;
 if not first.CustID and Ind then serial+1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Jan 2025 02:27:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-serial-number-by-CustID-with-related-to-IND-column/m-p/955443#M373138</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-01-08T02:27:05Z</dc:date>
    </item>
    <item>
      <title>Re: create serial number by CustID with related to IND column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-serial-number-by-CustID-with-related-to-IND-column/m-p/955456#M373143</link>
      <description>&lt;P&gt;No good,&lt;/P&gt;
&lt;P&gt;Look at customer 4 that I added now. He should start from serial 1 and not 2&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input CustID mon Ind;
cards;
111 1 0
111 2 0
111 3 1
111 4 0
111 5 0
111 6 0
111 7 0
111 8 0
111 9 1
111 10 0
111 11 0
111 12 0
222 1 0
222 2 0
222 3 0
222 4 0
222 5 0
222 6 0
222 7 0
222 8 0
222 9 0
222 10 0
222 11 0
222 12 0
333 1 0
333 2 0
333 3 0
444 1 1 
444 2 0 
444 3 0 
444 4 0 
444 5 0 
444 6 0 
444 7 0 
444 8 0 
444 9 1 
444 10 0 
444 11 0 
444 12 1 
;
Run;
data want;
input CustID mon Ind serial;
cards;
111 1 0 1
111 2 0 1
111 3 1 2
111 4 0 2
111 5 0 2
111 6 0 2
111 7 0 2
111 8 0 2
111 9 1 3
111 10 0 3
111 11 0 3
111 12 0 3
222 1 0 1
222 2 0 1
222 3 0 1
222 4 0 1
222 5 0 1
222 6 0 1
222 7 0 1
222 8 0 1
222 9 0 1
222 10 0 1
222 11 0 1
222 12 0 1
333 1 0 1
333 2 1 2
333 3 0 2
444 1 1 1 
444 2 0 1 
444 3 0 1  
444 4 0 1
444 5 0 1 
444 6 0 1 
444 7 0 1 
444 8 0 1 
444 9 1 2 
444 10 0 2  
444 11 0 2 
444 12 1 3 
;
Run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Jan 2025 07:51:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-serial-number-by-CustID-with-related-to-IND-column/m-p/955456#M373143</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2025-01-08T07:51:55Z</dc:date>
    </item>
    <item>
      <title>Re: create serial number by CustID with related to IND column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-serial-number-by-CustID-with-related-to-IND-column/m-p/955457#M373144</link>
      <description>&lt;P&gt;Please look at customer 5&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input CustID mon Ind;
cards;
111 1 0
111 2 0
111 3 1
111 4 0
111 5 0
111 6 0
111 7 0
111 8 0
111 9 1
111 10 0
111 11 0
111 12 0
222 1 0
222 2 0
222 3 0
222 4 0
222 5 0
222 6 0
222 7 0
222 8 0
222 9 0
222 10 0
222 11 0
222 12 0
333 1 0
333 2 0
333 3 0
444 1 1 
444 2 0 
444 3 0 
444 4 0 
444 5 0 
444 6 0 
444 7 0 
444 8 0 
444 9 1 
444 10 0 
444 11 0 
444 12 1 
555 1 0  
555 2 1  
555 3 1   
555 4 1 
555 5 1  
555 6 1  
555 7 1  
555 8 1  
555 9 1 
555 10 1   
555 11 1  
555 12 0 
;
Run;
data want;
input CustID mon Ind serial;
cards;
111 1 0 1
111 2 0 1
111 3 1 2
111 4 0 2
111 5 0 2
111 6 0 2
111 7 0 2
111 8 0 2
111 9 1 3
111 10 0 3
111 11 0 3
111 12 0 3
222 1 0 1
222 2 0 1
222 3 0 1
222 4 0 1
222 5 0 1
222 6 0 1
222 7 0 1
222 8 0 1
222 9 0 1
222 10 0 1
222 11 0 1
222 12 0 1
333 1 0 1
333 2 1 2
333 3 0 2
444 1 1 1 
444 2 0 1 
444 3 0 1  
444 4 0 1
444 5 0 1 
444 6 0 1 
444 7 0 1 
444 8 0 1 
444 9 1 2 
444 10 0 2  
444 11 0 2 
444 12 1 3 
555 1 0 1  
555 2 1 2 
555 3 1 3   
555 4 1 4 
555 5 1 5   
555 6 1 6 
555 7 1 7  
555 8 1 8  
555 9 1 9 
555 10 1 10   
555 11 1 11 
555 12 0 11
;
Run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Jan 2025 07:54:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-serial-number-by-CustID-with-related-to-IND-column/m-p/955457#M373144</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2025-01-08T07:54:23Z</dc:date>
    </item>
  </channel>
</rss>

