<?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: How to fill in some missing years in my data set in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-fill-in-some-missing-years-in-my-data-set/m-p/251447#M47512</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
     input year  ID $ number;
     cards;
     1977  A  23
     1978 A  27
     1984 B  99
     1987 B  101
     1991 B   107
     1953 C  11
     1957 C   17
;
run;

data want;
 merge have have( firstobs=2 keep=id year rename=(id=_id year=_year));
 output;
 if id=_id then do;
  do i=year+1 to _year-1;
   year=i;output;
  end;
 end;
 drop _: i;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 22 Feb 2016 02:08:57 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2016-02-22T02:08:57Z</dc:date>
    <item>
      <title>How to fill in some missing years in my data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-fill-in-some-missing-years-in-my-data-set/m-p/251406#M47496</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, I have this dataset:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
     input year $ ID $ number;
     cards;
     1977  A  23
     1978 A  27
     1984 B  99
     1987 B  101
     1991 B   107
     1953 C  11
     1957 C   17
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What I want to do is to fill in the missing in between years for each ID. For example, A has no missing becasue there is no missing year between the beginning and end of its years. However, I want to fill in for B with years 1985, 1986, and also 1988, 89, and 90. [ The other columns will be the same as the previous year]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So this is the WANT:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1977 A 23&lt;/P&gt;
&lt;P&gt;1978 A 27&lt;/P&gt;
&lt;P&gt;1984 B 99&lt;/P&gt;
&lt;P&gt;1985 B 99&lt;/P&gt;
&lt;P&gt;1986 B 99&lt;/P&gt;
&lt;P&gt;1987 B 101&lt;/P&gt;
&lt;P&gt;1988 B 101&lt;/P&gt;
&lt;P&gt;1989 B 101&lt;/P&gt;
&lt;P&gt;1990 B 101&lt;/P&gt;
&lt;P&gt;1991 B 107&lt;/P&gt;
&lt;P&gt;1953 C 11&lt;/P&gt;
&lt;P&gt;1954 C 11&lt;/P&gt;
&lt;P&gt;1955 C 11&lt;/P&gt;
&lt;P&gt;1956 C 11&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1957 C 11&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am aware of Proc Expand but did not find a way of working through different IDs. What is the best way to perform this exercise? Thanks a lot,&lt;/P&gt;</description>
      <pubDate>Sun, 21 Feb 2016 15:56:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-fill-in-some-missing-years-in-my-data-set/m-p/251406#M47496</guid>
      <dc:creator>Shayan2012</dc:creator>
      <dc:date>2016-02-21T15:56:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to fill in some missing years in my data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-fill-in-some-missing-years-in-my-data-set/m-p/251436#M47502</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
retain pyear pnumber;
tempy=year; tempn=number;
by id;
if first.id then do; pyear=year; pnumber=number;end;
else if year - pyear &amp;gt; 1 then do i=1 to (year-pyear-1);
	year=pyear+i;
	number=pnumber;
	output;
end;
year=tempy; number=tempn;
pyear=year; pnumber=number;
output;
drop pyear pnumber tempy tempn i;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 21 Feb 2016 21:55:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-fill-in-some-missing-years-in-my-data-set/m-p/251436#M47502</guid>
      <dc:creator>mohamed_zaki</dc:creator>
      <dc:date>2016-02-21T21:55:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to fill in some missing years in my data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-fill-in-some-missing-years-in-my-data-set/m-p/251447#M47512</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
     input year  ID $ number;
     cards;
     1977  A  23
     1978 A  27
     1984 B  99
     1987 B  101
     1991 B   107
     1953 C  11
     1957 C   17
;
run;

data want;
 merge have have( firstobs=2 keep=id year rename=(id=_id year=_year));
 output;
 if id=_id then do;
  do i=year+1 to _year-1;
   year=i;output;
  end;
 end;
 drop _: i;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 22 Feb 2016 02:08:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-fill-in-some-missing-years-in-my-data-set/m-p/251447#M47512</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-02-22T02:08:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to fill in some missing years in my data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-fill-in-some-missing-years-in-my-data-set/m-p/251571#M47561</link>
      <description>Wow! thanks a lot, Xia. That was so smart and neat.</description>
      <pubDate>Mon, 22 Feb 2016 16:12:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-fill-in-some-missing-years-in-my-data-set/m-p/251571#M47561</guid>
      <dc:creator>Shayan2012</dc:creator>
      <dc:date>2016-02-22T16:12:20Z</dc:date>
    </item>
  </channel>
</rss>

