<?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 a new row using current rows in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-a-new-row-using-current-rows/m-p/799578#M314426</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/50712"&gt;@jonatan_velarde&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would consider storing the two levels of ORDER (integer and decimal part in your description) in separate variables if possible.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
retain order1 order2 id;
retain status 'ok';
set have(rename=(order=order1));
do order2=., 1 to 3;
  output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thus you would avoid these potential issues:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Values like "&lt;EM&gt;m.n&lt;/EM&gt;" (with integers &lt;EM&gt;m&lt;/EM&gt; and &lt;EM&gt;n&lt;/EM&gt;) in a &lt;EM&gt;character&lt;/EM&gt; variable (as suggested by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;) would require precautions such as inserting leading blanks or zeros for the case that some of the&amp;nbsp;&lt;EM&gt;m&lt;/EM&gt; or &lt;EM&gt;n&lt;/EM&gt; get greater than 9. Otherwise, the default alphabetic sort order might not be satisfactory.&lt;/LI&gt;
&lt;LI&gt;&lt;EM&gt;Numeric&lt;/EM&gt; values &lt;EM&gt;m.n&lt;/EM&gt; are prone to numeric representation issues:&lt;BR /&gt;
&lt;PRE&gt;607   data _null_;
608   if 2.2+0.1 ne 2.3 then put 'Surprised?';
609   run;

Surprised?
NOTE: DATA statement used (Total process time):&lt;/PRE&gt;
So you would need to modify the other code suggestions (e.g., apply the ROUND function) to avoid unexpected results. Plus the issue if &lt;EM&gt;n&lt;/EM&gt;&amp;gt;9.&lt;/LI&gt;
&lt;/UL&gt;</description>
    <pubDate>Wed, 02 Mar 2022 14:56:33 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2022-03-02T14:56:33Z</dc:date>
    <item>
      <title>Create a new row using current rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-new-row-using-current-rows/m-p/799547#M314411</link>
      <description>&lt;P&gt;Good day:&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;I have this data set:&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;data have;&lt;/P&gt;
&lt;P&gt;input Order ID;&lt;/P&gt;
&lt;P&gt;cards;&lt;/P&gt;
&lt;P&gt;1 ROBERT&lt;/P&gt;
&lt;P&gt;2 CARLOS&lt;/P&gt;
&lt;P&gt;3 EDWARD&lt;/P&gt;
&lt;P&gt;4 JHON&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;now i need this:&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;ORDER ID STATUS&lt;/P&gt;
&lt;P&gt;1 ROBERT ok&lt;/P&gt;
&lt;P&gt;1.1 ROBERT ok&lt;/P&gt;
&lt;P&gt;1.2 ROBERT ok&lt;/P&gt;
&lt;P&gt;1.3 ROBERT ok&lt;/P&gt;
&lt;P&gt;2 CARLOS ok&lt;/P&gt;
&lt;P&gt;2.1 CARLOS ok&lt;/P&gt;
&lt;P&gt;2.2 CARLOS ok&lt;/P&gt;
&lt;P&gt;2.3 CARLOS ok&lt;/P&gt;
&lt;P&gt;3 EDWARD ok&lt;/P&gt;
&lt;P&gt;3.1 EDWARD ok&lt;/P&gt;
&lt;P&gt;3.2 EDWARD ok&lt;/P&gt;
&lt;P&gt;3.3 EDWARD ok&lt;/P&gt;
&lt;P&gt;4 JHON ok&lt;/P&gt;
&lt;P&gt;4.1 JHON ok&lt;/P&gt;
&lt;P&gt;4.2 JHON ok&lt;/P&gt;
&lt;P&gt;4.3 JHON ok&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2022 11:34:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-new-row-using-current-rows/m-p/799547#M314411</guid>
      <dc:creator>jonatan_velarde</dc:creator>
      <dc:date>2022-03-02T11:34:36Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new row using current rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-new-row-using-current-rows/m-p/799549#M314412</link>
      <description>&lt;PRE&gt;data have;
input Order ID $;
cards;
1 ROBERT
2 CARLOS
3 EDWARD
4 JHON
;

data want;
 set have;
 status='ok';
output;
 do i=1 to 3;
  order=order+0.1;output;
 end;
 drop i;
run;&lt;/PRE&gt;</description>
      <pubDate>Wed, 02 Mar 2022 12:44:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-new-row-using-current-rows/m-p/799549#M314412</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-03-02T12:44:11Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new row using current rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-new-row-using-current-rows/m-p/799550#M314413</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Order ID $;
cards;
1 ROBERT 
2 CARLOS 
3 EDWARD 
4 JHON   
;

data want(drop = i o);
   set have(rename = Order = o);
   status = 'ok';
   order = put(o, 8. -l);
   output;
   do i = 1 to 3;
      order = catx('.', cats(o), i);
	  output;
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 02 Mar 2022 12:12:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-new-row-using-current-rows/m-p/799550#M314413</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-03-02T12:12:09Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new row using current rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-new-row-using-current-rows/m-p/799556#M314417</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/50712"&gt;@jonatan_velarde&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How about:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
   input Order ID $8.;
   cards;
1 ROBERT
2 CARLOS
3 EDWARD
4 JHON
;


data want(drop = i);
   set have;

   retain status 'OK';

   do i = 1 to 4;
      output;
      order = order + 0.1;
   end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards,&lt;/P&gt;
&lt;P&gt;Amir.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2022 12:40:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-new-row-using-current-rows/m-p/799556#M314417</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2022-03-02T12:40:55Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new row using current rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-new-row-using-current-rows/m-p/799557#M314418</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/50712"&gt;@jonatan_velarde&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another alternative:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
   input Order ID $8.;
   cards;
1 ROBERT
2 CARLOS
3 EDWARD
4 JHON
;


data want;
   set have;

   retain status 'OK';

   do order = order to (order + 0.3) by 0.1;
      output;
   end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards,&lt;/P&gt;
&lt;P&gt;Amir.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2022 12:48:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-new-row-using-current-rows/m-p/799557#M314418</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2022-03-02T12:48:18Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new row using current rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-new-row-using-current-rows/m-p/799578#M314426</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/50712"&gt;@jonatan_velarde&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would consider storing the two levels of ORDER (integer and decimal part in your description) in separate variables if possible.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
retain order1 order2 id;
retain status 'ok';
set have(rename=(order=order1));
do order2=., 1 to 3;
  output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thus you would avoid these potential issues:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Values like "&lt;EM&gt;m.n&lt;/EM&gt;" (with integers &lt;EM&gt;m&lt;/EM&gt; and &lt;EM&gt;n&lt;/EM&gt;) in a &lt;EM&gt;character&lt;/EM&gt; variable (as suggested by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;) would require precautions such as inserting leading blanks or zeros for the case that some of the&amp;nbsp;&lt;EM&gt;m&lt;/EM&gt; or &lt;EM&gt;n&lt;/EM&gt; get greater than 9. Otherwise, the default alphabetic sort order might not be satisfactory.&lt;/LI&gt;
&lt;LI&gt;&lt;EM&gt;Numeric&lt;/EM&gt; values &lt;EM&gt;m.n&lt;/EM&gt; are prone to numeric representation issues:&lt;BR /&gt;
&lt;PRE&gt;607   data _null_;
608   if 2.2+0.1 ne 2.3 then put 'Surprised?';
609   run;

Surprised?
NOTE: DATA statement used (Total process time):&lt;/PRE&gt;
So you would need to modify the other code suggestions (e.g., apply the ROUND function) to avoid unexpected results. Plus the issue if &lt;EM&gt;n&lt;/EM&gt;&amp;gt;9.&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Wed, 02 Mar 2022 14:56:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-new-row-using-current-rows/m-p/799578#M314426</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2022-03-02T14:56:33Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new row using current rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-new-row-using-current-rows/m-p/799586#M314431</link>
      <description>&lt;P&gt;Another approach, using Cartesian product, that also gives you the flexibility of using letters, example, in the order variable.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Order ID $;
cards;
1 ROBERT 
2 CARLOS 
3 EDWARD 
4 JHON   
;
data seq;
  input n;
cards;
0.0
0.1
0.2
0.3
;  
proc sql;
   create table Cart as
   select have.*,seq.*
   from have, seq;
quit;
data want;
   set Cart;
      retain status 'ok';
     Order=order+n;
     drop n;
 run;
proc sort;
  by Order ID;
run;
proc print;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ghosh_0-1646235029834.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/69067i0FB3652A71FC0C53/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ghosh_0-1646235029834.png" alt="ghosh_0-1646235029834.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2022 15:31:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-new-row-using-current-rows/m-p/799586#M314431</guid>
      <dc:creator>ghosh</dc:creator>
      <dc:date>2022-03-02T15:31:09Z</dc:date>
    </item>
  </channel>
</rss>

