<?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: 'complete' function in sas or similar? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/complete-function-in-sas-or-similar/m-p/815575#M81839</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

data have;
   infile datalines delimiter='	'; 
   input group	count n;
   datalines;                      
9	1	400
9	2	297
9	3	344
9	4	32
9	5	45
9	6	6
9	7	54
9	8	34
9	9	21
10	1	32
10	2	3
10	3	57
10	4	43
10	5	45
10	6	45
10	7	34
10	8	32
10	11	5
;

data want;
 merge have have(firstobs=2 keep=group count rename=(group=_group count=_count));
 output;
 if group=_group then do;
  do count=count+1 to _count-1;
    n=0;output;
  end;
 end;
drop _group _count;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 29 May 2022 09:43:37 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2022-05-29T09:43:37Z</dc:date>
    <item>
      <title>'complete' function in sas or similar?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/complete-function-in-sas-or-similar/m-p/815556#M81833</link>
      <description>&lt;P&gt;say I have something like:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data have;
   infile datalines delimiter='	'; 
   input group	count n;
   datalines;                      
9	1	400
9	2	297
9	3	344
9	4	32
9	5	45
9	6	6
9	7	54
9	8	34
9	9	21
10	1	32
10	2	3
10	3	57
10	4	43
10	5	45
10	6	45
10	7	34
10	8	32
10	11	5
;



&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;but for group 10 I need to fill in missing count values per group, so I want count=9 and 10, while for n just fill in 0. Like below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data have;
   infile datalines delimiter='	'; 
   input group	count n;
   datalines;                      
9	1	400
9	2	297
9	3	344
9	4	32
9	5	45
9	6	6
9	7	54
9	8	34
9	9	21
10	1	32
10	2	3
10	3	57
10	4	43
10	5	45
10	6	45
10	7	34
10	8	32
10	9	0
10	10	0
10	11	5
;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I'm thinking there has to be a complete function or similar. Help is appreciated!!&lt;/P&gt;</description>
      <pubDate>Sat, 28 May 2022 19:15:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/complete-function-in-sas-or-similar/m-p/815556#M81833</guid>
      <dc:creator>richart</dc:creator>
      <dc:date>2022-05-28T19:15:42Z</dc:date>
    </item>
    <item>
      <title>Re: 'complete' function in sas or similar?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/complete-function-in-sas-or-similar/m-p/815558#M81834</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/240551"&gt;@richart&lt;/a&gt;&amp;nbsp; I believe there might be some inbuilt procedures within the SAS ETS module should you have time series dates in your real data to fill. Of course, otherwise you can always rely on a datastep-&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;


data have;
   infile datalines delimiter='	'; 
   input group	count n;
   datalines;                      
9	1	400
9	2	297
9	3	344
9	4	32
9	5	45
9	6	6
9	7	54
9	8	34
9	9	21
10	1	32
10	2	3
10	3	57
10	4	43
10	5	45
10	6	45
10	7	34
10	8	32
10	11	5
;



data want ;
  do until (last.group) ;
    set have curobs = _n ;
	by group ;
	if _c and dif(count) &amp;gt; 1 then do ;
	  do count = _c + 1 to count - 1 ;
	    n = 0 ;
		output ;
	  end ;
	  set have point = _n ;
	  output ;
	end ;
	else output ;
	_c =count ;
  end ;
  drop _c ;
run ;
	    &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 28 May 2022 20:35:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/complete-function-in-sas-or-similar/m-p/815558#M81834</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2022-05-28T20:35:34Z</dc:date>
    </item>
    <item>
      <title>Re: 'complete' function in sas or similar?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/complete-function-in-sas-or-similar/m-p/815560#M81836</link>
      <description>&lt;P&gt;Assuming that max possible value of count is known, you can do something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  array temp[100] _temporary_ ; /* set it big enough */
  set have;
  by group;

  temp[count] = n;
  _max_ = max(count, _max_);

  if last.group then
    do;
      do count =  1 to _max_;
        n = coalesce(temp[count], 0);
        output;
      end;
      call missing(of temp[*], _max_);
    end;
    drop _max_;
run;
proc print;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Sat, 28 May 2022 20:54:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/complete-function-in-sas-or-similar/m-p/815560#M81836</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2022-05-28T20:54:43Z</dc:date>
    </item>
    <item>
      <title>Re: 'complete' function in sas or similar?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/complete-function-in-sas-or-similar/m-p/815574#M81838</link>
      <description>&lt;P&gt;Here another coding variant that should work.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  by group count;
  output;
  _lag_count=coalesce(lag(count),1);
  do while(coalesce(count,1) - _lag_count &amp;gt; 1);
    count=count-1;
    n=0;
    output;
  end;
  drop _lag_count;
run;

proc sort data=want;
  by group count;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 29 May 2022 08:28:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/complete-function-in-sas-or-similar/m-p/815574#M81838</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2022-05-29T08:28:49Z</dc:date>
    </item>
    <item>
      <title>Re: 'complete' function in sas or similar?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/complete-function-in-sas-or-similar/m-p/815575#M81839</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

data have;
   infile datalines delimiter='	'; 
   input group	count n;
   datalines;                      
9	1	400
9	2	297
9	3	344
9	4	32
9	5	45
9	6	6
9	7	54
9	8	34
9	9	21
10	1	32
10	2	3
10	3	57
10	4	43
10	5	45
10	6	45
10	7	34
10	8	32
10	11	5
;

data want;
 merge have have(firstobs=2 keep=group count rename=(group=_group count=_count));
 output;
 if group=_group then do;
  do count=count+1 to _count-1;
    n=0;output;
  end;
 end;
drop _group _count;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 29 May 2022 09:43:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/complete-function-in-sas-or-similar/m-p/815575#M81839</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-05-29T09:43:37Z</dc:date>
    </item>
    <item>
      <title>Re: 'complete' function in sas or similar?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/complete-function-in-sas-or-similar/m-p/815580#M81841</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/240551"&gt;@richart&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The SAS/ETS way as&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;is suggesting :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC TIMESERIES data=have out=want;
   by group;
   id count     interval=day
                accumulate=median
                setmiss=0 ;
   var n;
   format count 5.;
run;
/* end of program */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;Koen&lt;/P&gt;</description>
      <pubDate>Sun, 29 May 2022 11:59:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/complete-function-in-sas-or-similar/m-p/815580#M81841</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2022-05-29T11:59:29Z</dc:date>
    </item>
  </channel>
</rss>

