<?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: need to add new row in existing dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/need-to-add-new-row-in-existing-dataset/m-p/700643#M214438</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/357866"&gt;@PrathameshP&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your suggestion won't work.&amp;nbsp; The inserts need to be conditioned on some comparison.&lt;/P&gt;</description>
    <pubDate>Sat, 21 Nov 2020 03:53:38 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2020-11-21T03:53:38Z</dc:date>
    <item>
      <title>need to add new row in existing dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/need-to-add-new-row-in-existing-dataset/m-p/398037#M96234</link>
      <description>&lt;P&gt;Attached data. what i need is if&amp;nbsp;PDCTREAS(resons for withdrawal is present then add a row in desc and desc_fmt and value for treatment as 1 . i am trying the below code but it doesnt work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if PDCTREAS ne "" then do; &lt;BR /&gt; desc= "ByPrim";&lt;BR /&gt; dsreas_num_trt= 1;&lt;BR /&gt; dsreas_fmt = " "||PDCTREAS;&lt;BR /&gt; sort1 = 88; &lt;BR /&gt; output;&lt;BR /&gt; end;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Sep 2017 10:46:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/need-to-add-new-row-in-existing-dataset/m-p/398037#M96234</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2017-09-22T10:46:33Z</dc:date>
    </item>
    <item>
      <title>Re: need to add new row in existing dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/need-to-add-new-row-in-existing-dataset/m-p/398043#M96236</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/62004"&gt;@vraj1&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Without looking into the attached data set I believe what you're missing is an OUTPUT statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* option 1 */
data old;
  set old;
  OUTPUT;
  if &amp;lt;some condition&amp;gt; then
    do;
      varA=1;
      ...
      OUTPUT;
    end;
run;

/* option 2: "better" */
data new_stuff;
  set old;
  if &amp;lt;some condition&amp;gt; then
    do;
      varA=1;
      ...
      OUTPUT;
    end;
run;

proc append base=old data=new_stuff;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Sep 2017 10:56:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/need-to-add-new-row-in-existing-dataset/m-p/398043#M96236</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-09-22T10:56:21Z</dc:date>
    </item>
    <item>
      <title>Re: need to add new row in existing dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/need-to-add-new-row-in-existing-dataset/m-p/398044#M96237</link>
      <description>&lt;P&gt;If i use the condition&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if PDCTREAS ne "" then do; &amp;nbsp;then it removes everything which is missing but i need all the data and add new variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am not able to find out a way&lt;/P&gt;</description>
      <pubDate>Fri, 22 Sep 2017 11:00:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/need-to-add-new-row-in-existing-dataset/m-p/398044#M96237</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2017-09-22T11:00:32Z</dc:date>
    </item>
    <item>
      <title>Re: need to add new row in existing dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/need-to-add-new-row-in-existing-dataset/m-p/398045#M96238</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/62004"&gt;@vraj1&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;That's why you need a first OUTPUT statement right after the SET statement. This will write all observations from the input data set directly to the output data set.&lt;/P&gt;
&lt;P&gt;Then comes your condition. Whenever the condition is TRUE you're doing additional variable assignments and then you're issuing an additional OUTPUT statements which writes another row to the output table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;... or even better: Just collect all new rows into a table and then append this table to your original data set (that's Option 2).&lt;/P&gt;</description>
      <pubDate>Fri, 22 Sep 2017 11:05:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/need-to-add-new-row-in-existing-dataset/m-p/398045#M96238</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-09-22T11:05:04Z</dc:date>
    </item>
    <item>
      <title>Re: need to add new row in existing dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/need-to-add-new-row-in-existing-dataset/m-p/700412#M214349</link>
      <description>proc sql;&lt;BR /&gt;create table WANT like HAVE;&lt;BR /&gt;quit;&lt;BR /&gt;&lt;BR /&gt;proc sql; insert into WANT (var1, var2, var3)&lt;BR /&gt;values (123,'ABC','01JAN2020'D)&lt;BR /&gt;values (456,'EFG','20NOV2020'D);&lt;BR /&gt;quit;</description>
      <pubDate>Fri, 20 Nov 2020 08:27:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/need-to-add-new-row-in-existing-dataset/m-p/700412#M214349</guid>
      <dc:creator>PrathameshP</dc:creator>
      <dc:date>2020-11-20T08:27:25Z</dc:date>
    </item>
    <item>
      <title>Re: need to add new row in existing dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/need-to-add-new-row-in-existing-dataset/m-p/700643#M214438</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/357866"&gt;@PrathameshP&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your suggestion won't work.&amp;nbsp; The inserts need to be conditioned on some comparison.&lt;/P&gt;</description>
      <pubDate>Sat, 21 Nov 2020 03:53:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/need-to-add-new-row-in-existing-dataset/m-p/700643#M214438</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2020-11-21T03:53:38Z</dc:date>
    </item>
  </channel>
</rss>

