<?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 Continue the Count value in the existing variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Continue-the-Count-value-in-the-existing-variable/m-p/561549#M157225</link>
    <description>&lt;P&gt;Hi Experts,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset which contains 3 visits to ID.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Id Count var1;
cards;
12 1 56
12 2 45
12 3 65
25 1 87
25 2 98
25 3 23
;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Now I added,&amp;nbsp;&lt;/P&gt;&lt;P&gt;15 nos - 12&amp;nbsp;&lt;/P&gt;&lt;P&gt;20 nos - 25 in the Id variable. (Only Id not other variables)&lt;/P&gt;&lt;P&gt;I have to continue the count value as followed which already exist.&lt;/P&gt;&lt;P&gt;Please suggest some Ideas to solve this problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 25 May 2019 08:06:18 GMT</pubDate>
    <dc:creator>Sathish_jammy</dc:creator>
    <dc:date>2019-05-25T08:06:18Z</dc:date>
    <item>
      <title>Continue the Count value in the existing variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Continue-the-Count-value-in-the-existing-variable/m-p/561549#M157225</link>
      <description>&lt;P&gt;Hi Experts,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset which contains 3 visits to ID.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Id Count var1;
cards;
12 1 56
12 2 45
12 3 65
25 1 87
25 2 98
25 3 23
;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Now I added,&amp;nbsp;&lt;/P&gt;&lt;P&gt;15 nos - 12&amp;nbsp;&lt;/P&gt;&lt;P&gt;20 nos - 25 in the Id variable. (Only Id not other variables)&lt;/P&gt;&lt;P&gt;I have to continue the count value as followed which already exist.&lt;/P&gt;&lt;P&gt;Please suggest some Ideas to solve this problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 25 May 2019 08:06:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Continue-the-Count-value-in-the-existing-variable/m-p/561549#M157225</guid>
      <dc:creator>Sathish_jammy</dc:creator>
      <dc:date>2019-05-25T08:06:18Z</dc:date>
    </item>
    <item>
      <title>Re: Continue the Count value in the existing variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Continue-the-Count-value-in-the-existing-variable/m-p/561550#M157226</link>
      <description>&lt;P&gt;I don't understand.&amp;nbsp; Post two data steps:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your changes:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Now I added,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;15 nos - 12&amp;nbsp;&lt;/P&gt;
&lt;P&gt;20 nos - 25 in the Id variable. (Only Id not other variables)&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And your desired results:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;I have to continue the count value as followed which already exist.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Huh??? What are you trying to say here?&lt;/P&gt;</description>
      <pubDate>Sat, 25 May 2019 09:12:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Continue-the-Count-value-in-the-existing-variable/m-p/561550#M157226</guid>
      <dc:creator>ScottBass</dc:creator>
      <dc:date>2019-05-25T09:12:34Z</dc:date>
    </item>
    <item>
      <title>Re: Continue the Count value in the existing variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Continue-the-Count-value-in-the-existing-variable/m-p/561551#M157227</link>
      <description>&lt;P&gt;Dear &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15043"&gt;@ScottBass&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm Sorry for the trouble, Let me explain in detail...&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Dataset1;
input Id Count var1;
cards;
12 1 56
12 2 45
12 3 65
25 1 87
25 2 98
25 3 23
;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Dataset2;
input Id;
cards;
12
12
12
12
12
25
25
25
25
;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I merged these 2 datasets as given below. I need to continue the Count value (Mentioned in Bold) which followed by the existing value from 3.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Id&lt;/TD&gt;&lt;TD&gt;Count&lt;/TD&gt;&lt;TD&gt;Var1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;56&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12&lt;/TD&gt;&lt;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/TD&gt;&lt;TD&gt;&lt;STRONG&gt;4&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;25&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;5&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;25&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;6&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;25&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;7&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 25 May 2019 09:43:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Continue-the-Count-value-in-the-existing-variable/m-p/561551#M157227</guid>
      <dc:creator>Sathish_jammy</dc:creator>
      <dc:date>2019-05-25T09:43:08Z</dc:date>
    </item>
    <item>
      <title>Re: Continue the Count value in the existing variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Continue-the-Count-value-in-the-existing-variable/m-p/561554#M157229</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Dataset1;
input Id Count var1;
cards;
12 1 56
12 2 45
12 3 65
25 1 87
25 2 98
25 3 23
;
data Dataset2;
input Id;
cards;
12
12
12
12
12
25
25
25
25
;

data temp;
 set dataset1 dataset2(in=inb);
 by id;
 flag=inb;
 drop count;
run;
data want;
 set temp;
 by id;
 if first.id then count=0;
 count+1;
run;
proc sort data=want;
by flag id;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 25 May 2019 11:15:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Continue-the-Count-value-in-the-existing-variable/m-p/561554#M157229</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-05-25T11:15:24Z</dc:date>
    </item>
    <item>
      <title>Re: Continue the Count value in the existing variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Continue-the-Count-value-in-the-existing-variable/m-p/561555#M157230</link>
      <description>&lt;P&gt;Just to be clear, Var1 will have missing values for those observations, correct?&lt;/P&gt;</description>
      <pubDate>Sat, 25 May 2019 11:15:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Continue-the-Count-value-in-the-existing-variable/m-p/561555#M157230</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-05-25T11:15:45Z</dc:date>
    </item>
    <item>
      <title>Re: Continue the Count value in the existing variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Continue-the-Count-value-in-the-existing-variable/m-p/561557#M157232</link>
      <description>&lt;P&gt;Exactly...&lt;/P&gt;</description>
      <pubDate>Sat, 25 May 2019 11:41:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Continue-the-Count-value-in-the-existing-variable/m-p/561557#M157232</guid>
      <dc:creator>Sathish_jammy</dc:creator>
      <dc:date>2019-05-25T11:41:04Z</dc:date>
    </item>
    <item>
      <title>Re: Continue the Count value in the existing variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Continue-the-Count-value-in-the-existing-variable/m-p/561558#M157233</link>
      <description>&lt;P&gt;The desired result is in Dataset1 with this approach&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data temp;
   do until (last.Id);
      set Dataset1;
      by Id;
   end;
   call missing(var1);
   do until (last.Id);
      set Dataset2;
      by Id;
      Count=Count+1;
      output;
   end;
run;

proc append base=Dataset1 data=temp;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 25 May 2019 11:46:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Continue-the-Count-value-in-the-existing-variable/m-p/561558#M157233</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-05-25T11:46:46Z</dc:date>
    </item>
  </channel>
</rss>

