<?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 How can I insert rows? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-can-I-insert-rows/m-p/75354#M21851</link>
    <description>Hi ,&lt;BR /&gt;
i have a dataset with variable "a" that has 3 values: 0, 1, 2. I want to insert rows for the missing values in a dataset like this:&lt;BR /&gt;
&lt;BR /&gt;
data a;&lt;BR /&gt;
input a b;&lt;BR /&gt;
cards ;&lt;BR /&gt;
0 1&lt;BR /&gt;
1 2&lt;BR /&gt;
2 3&lt;BR /&gt;
0 1&lt;BR /&gt;
2 5&lt;BR /&gt;
0 3&lt;BR /&gt;
1 4&lt;BR /&gt;
...&lt;BR /&gt;
...&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
i want my output will be like this :&lt;BR /&gt;
&lt;BR /&gt;
0 1&lt;BR /&gt;
1 2&lt;BR /&gt;
2 3&lt;BR /&gt;
0 1&lt;BR /&gt;
1 .&lt;BR /&gt;
2 5&lt;BR /&gt;
0 3&lt;BR /&gt;
1 4&lt;BR /&gt;
2 .&lt;BR /&gt;
Thank you very much in advance&lt;BR /&gt;
&lt;BR /&gt;
Simone</description>
    <pubDate>Thu, 15 Apr 2010 07:49:55 GMT</pubDate>
    <dc:creator>HDSimo</dc:creator>
    <dc:date>2010-04-15T07:49:55Z</dc:date>
    <item>
      <title>How can I insert rows?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-can-I-insert-rows/m-p/75354#M21851</link>
      <description>Hi ,&lt;BR /&gt;
i have a dataset with variable "a" that has 3 values: 0, 1, 2. I want to insert rows for the missing values in a dataset like this:&lt;BR /&gt;
&lt;BR /&gt;
data a;&lt;BR /&gt;
input a b;&lt;BR /&gt;
cards ;&lt;BR /&gt;
0 1&lt;BR /&gt;
1 2&lt;BR /&gt;
2 3&lt;BR /&gt;
0 1&lt;BR /&gt;
2 5&lt;BR /&gt;
0 3&lt;BR /&gt;
1 4&lt;BR /&gt;
...&lt;BR /&gt;
...&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
i want my output will be like this :&lt;BR /&gt;
&lt;BR /&gt;
0 1&lt;BR /&gt;
1 2&lt;BR /&gt;
2 3&lt;BR /&gt;
0 1&lt;BR /&gt;
1 .&lt;BR /&gt;
2 5&lt;BR /&gt;
0 3&lt;BR /&gt;
1 4&lt;BR /&gt;
2 .&lt;BR /&gt;
Thank you very much in advance&lt;BR /&gt;
&lt;BR /&gt;
Simone</description>
      <pubDate>Thu, 15 Apr 2010 07:49:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-can-I-insert-rows/m-p/75354#M21851</guid>
      <dc:creator>HDSimo</dc:creator>
      <dc:date>2010-04-15T07:49:55Z</dc:date>
    </item>
    <item>
      <title>Re: How can I insert rows?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-can-I-insert-rows/m-p/75355#M21852</link>
      <description>My solution...&lt;BR /&gt;
&lt;BR /&gt;
data new; retain i -1;&lt;BR /&gt;
if i=2 then i=0; else i=i+1;&lt;BR /&gt;
set a;&lt;BR /&gt;
if i = a then output;&lt;BR /&gt;
else do;&lt;BR /&gt;
a=i; b=0;output;&lt;BR /&gt;
end;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Simone</description>
      <pubDate>Thu, 15 Apr 2010 08:29:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-can-I-insert-rows/m-p/75355#M21852</guid>
      <dc:creator>HDSimo</dc:creator>
      <dc:date>2010-04-15T08:29:21Z</dc:date>
    </item>
    <item>
      <title>Re: How can I insert rows?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-can-I-insert-rows/m-p/75356#M21853</link>
      <description>Arghhh! It doesn't work?&lt;BR /&gt;
Help please!</description>
      <pubDate>Thu, 15 Apr 2010 09:20:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-can-I-insert-rows/m-p/75356#M21853</guid>
      <dc:creator>HDSimo</dc:creator>
      <dc:date>2010-04-15T09:20:13Z</dc:date>
    </item>
    <item>
      <title>Re: How can I insert rows?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-can-I-insert-rows/m-p/75357#M21854</link>
      <description>data Have;&lt;BR /&gt;
input a b;&lt;BR /&gt;
cards ;&lt;BR /&gt;
0 1&lt;BR /&gt;
1 2&lt;BR /&gt;
2 3&lt;BR /&gt;
0 1&lt;BR /&gt;
2 5&lt;BR /&gt;
1 1&lt;BR /&gt;
2 1&lt;BR /&gt;
1 3&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data want(keep=a b);&lt;BR /&gt;
	set have end=last;&lt;BR /&gt;
  retain counter 0 RetA RetB;&lt;BR /&gt;
  RetA=a;&lt;BR /&gt;
  RetB=b;&lt;BR /&gt;
  if counter&amp;gt;2 then counter=0;&lt;BR /&gt;
  do until( (counter&amp;gt;RetA and not last) or (last and counter&amp;gt;2));&lt;BR /&gt;
    if RetA=counter then &lt;BR /&gt;
    do;&lt;BR /&gt;
      a=RetA;&lt;BR /&gt;
      b=RetB;&lt;BR /&gt;
    end;&lt;BR /&gt;
    else&lt;BR /&gt;
    do;&lt;BR /&gt;
      a=counter;&lt;BR /&gt;
      call missing(b);&lt;BR /&gt;
    end;&lt;BR /&gt;
    output;&lt;BR /&gt;
    counter+1;&lt;BR /&gt;
  end;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc print data=want;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
HTH&lt;BR /&gt;
Patrick</description>
      <pubDate>Thu, 15 Apr 2010 13:15:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-can-I-insert-rows/m-p/75357#M21854</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2010-04-15T13:15:56Z</dc:date>
    </item>
  </channel>
</rss>

