<?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: add rows to an existing data file (mod like in file statement possible?) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/add-rows-to-an-existing-data-file-mod-like-in-file-statement/m-p/152255#M29981</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There is MODIFY for data step and you can use it to APPEND records among other things.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 25 Nov 2013 15:47:28 GMT</pubDate>
    <dc:creator>data_null__</dc:creator>
    <dc:date>2013-11-25T15:47:28Z</dc:date>
    <item>
      <title>add rows to an existing data file (mod like in file statement possible?)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/add-rows-to-an-existing-data-file-mod-like-in-file-statement/m-p/152248#M29974</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a macro %do iteration which contains a data step:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let mylist = 123:444:647;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%do i=1 to 3 by 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let var_i = %scan(&amp;amp;mylist,&amp;amp;i,":");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; proc sql noprint;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select organisation :into org_number separated by "," from report.organisations where xy=&amp;amp;var_i;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data work.myfullresult;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set report.mybigdata;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where org in (org_number);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; my_new_var = %var_i;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; drop my_old_var;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now the file work.myfullresult contains only the rows for the last %do iteration because the last work.myfullresult overwrites the one before.&lt;/P&gt;&lt;P&gt;My aim however is to have all rows of all iterations in one final data set.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This reminds me of the mod (modify) attribute for the file statement which add news rows to the existing file.&lt;/P&gt;&lt;P&gt;Is there anything like that for the data step?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;Eva&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Nov 2013 17:05:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/add-rows-to-an-existing-data-file-mod-like-in-file-statement/m-p/152248#M29974</guid>
      <dc:creator>Eva</dc:creator>
      <dc:date>2013-11-21T17:05:50Z</dc:date>
    </item>
    <item>
      <title>Re: add rows to an existing data file (mod like in file statement possible?)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/add-rows-to-an-existing-data-file-mod-like-in-file-statement/m-p/152249#M29975</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;PROC APPEND will work&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, you could rewrite the SQL to pull all organisation numbers from all values in &amp;amp;mylist instead of just those where xy=&amp;amp;var_i&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Nov 2013 17:21:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/add-rows-to-an-existing-data-file-mod-like-in-file-statement/m-p/152249#M29975</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2013-11-21T17:21:03Z</dc:date>
    </item>
    <item>
      <title>Re: add rows to an existing data file (mod like in file statement possible?)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/add-rows-to-an-existing-data-file-mod-like-in-file-statement/m-p/152250#M29976</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Have you considered PROC APPEND?&lt;/P&gt;&lt;P&gt;The mod/append functionality in a datastep&amp;nbsp; that corresponds to FILE statement MOD option would the the OUTPUT statement in a data step writing a dataset with a MODIFY statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think the PROC APPEND approach is easier to code. If performance is an issue for large data, then instead of creating a dataset create a view. Then the data are created as the PROC APPEND runs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;peter.c&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Nov 2013 17:25:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/add-rows-to-an-existing-data-file-mod-like-in-file-statement/m-p/152250#M29976</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2013-11-21T17:25:09Z</dc:date>
    </item>
    <item>
      <title>Re: add rows to an existing data file (mod like in file statement possible?)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/add-rows-to-an-existing-data-file-mod-like-in-file-statement/m-p/152251#M29977</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Proc append is probably what you're looking for:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And i think org_number in your query should be &amp;amp;org_number. and %var_i should be &amp;amp;var_i&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let mylist = 123:444:647;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%do i=1 to 3 by 1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*remove old version of final file if it exists;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;drop table final_results;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let var_i = %scan(&amp;amp;mylist,&amp;amp;i,":");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; proc sql noprint;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select organisation :into org_number separated by "," from report.organisations where xy=&amp;amp;var_i;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data work.myfullresult;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set report.mybigdata;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where org in (&amp;amp;org_number);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; my_new_var = &amp;amp;var_i;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; drop my_old_var;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc append base=final_results data=myfullresult;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Nov 2013 17:26:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/add-rows-to-an-existing-data-file-mod-like-in-file-statement/m-p/152251#M29977</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-11-21T17:26:59Z</dc:date>
    </item>
    <item>
      <title>Re: add rows to an existing data file (mod like in file statement possible?)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/add-rows-to-an-existing-data-file-mod-like-in-file-statement/m-p/152252#M29978</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks a lot for your great feedback! I solved it with proc append.&lt;/P&gt;&lt;P&gt;What a pity that there is no "modify" for the data step &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Nov 2013 13:44:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/add-rows-to-an-existing-data-file-mod-like-in-file-statement/m-p/152252#M29978</guid>
      <dc:creator>Eva</dc:creator>
      <dc:date>2013-11-25T13:44:21Z</dc:date>
    </item>
    <item>
      <title>Re: add rows to an existing data file (mod like in file statement possible?)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/add-rows-to-an-existing-data-file-mod-like-in-file-statement/m-p/152253#M29979</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;can anyone pls tell me what 123:444:647 means?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Nov 2013 15:01:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/add-rows-to-an-existing-data-file-mod-like-in-file-statement/m-p/152253#M29979</guid>
      <dc:creator>Tal</dc:creator>
      <dc:date>2013-11-25T15:01:58Z</dc:date>
    </item>
    <item>
      <title>Re: add rows to an existing data file (mod like in file statement possible?)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/add-rows-to-an-existing-data-file-mod-like-in-file-statement/m-p/152254#M29980</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Perhaps your real problem is more complex, but why are you looping when you could pull all of the records in one query instead?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%let mylist = 123,444,647;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;proc sql noprint ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; create table work.myfullresults as&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; select a.*,b.organisation as my_new_var&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; from report.mybigdata a&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , report.organization b&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; where a.org = b.organisation&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; and b.xy in (&amp;amp;mylist)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Nov 2013 15:32:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/add-rows-to-an-existing-data-file-mod-like-in-file-statement/m-p/152254#M29980</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-11-25T15:32:08Z</dc:date>
    </item>
    <item>
      <title>Re: add rows to an existing data file (mod like in file statement possible?)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/add-rows-to-an-existing-data-file-mod-like-in-file-statement/m-p/152255#M29981</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There is MODIFY for data step and you can use it to APPEND records among other things.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Nov 2013 15:47:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/add-rows-to-an-existing-data-file-mod-like-in-file-statement/m-p/152255#M29981</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2013-11-25T15:47:28Z</dc:date>
    </item>
    <item>
      <title>Re: add rows to an existing data file (mod like in file statement possible?)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/add-rows-to-an-existing-data-file-mod-like-in-file-statement/m-p/152256#M29982</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I guess Tom's answer is a great one. There is really no need to iterate in this case.&amp;nbsp; If you insist using iteration as you did, you can either use proc append, the SQL Drop mentioned in Reeza should be outside the loop and you might have a warning if the dataset was not exist at first!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And please let me point out something (no offense):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let mylist = 123:444:647;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%do i=1 to 3 by 1;&amp;nbsp; /*(%to %by??)*/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let var_i = %scan(&amp;amp;mylist,&amp;amp;i,":"); /* (:, no need for " ")*/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; proc sql noprint;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select organisation :into org_number separated by "," from report.organisations where xy=&amp;amp;var_i; /*(do you need " " here??)*/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data work.myfullresult;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set report.mybigdata;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where org in (org_number);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; my_new_var = %var_i; /*&amp;amp;var_i*/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; drop my_old_var;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Nov 2013 15:48:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/add-rows-to-an-existing-data-file-mod-like-in-file-statement/m-p/152256#M29982</guid>
      <dc:creator>Robertguo</dc:creator>
      <dc:date>2013-11-25T15:48:02Z</dc:date>
    </item>
  </channel>
</rss>

