<?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 ERROR 457-185: The REPLACE statement is not valid on a data set that is opened for OUTPUT. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/ERROR-457-185-The-REPLACE-statement-is-not-valid-on-a-data-set/m-p/598719#M172688</link>
    <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We have an input excel that we read some data from multiple sources by vba and then importing some of it to the sas lib. We are aiming to import the new day data everyday and cumulate the data date by date in one table.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;for ex: we have a currency fx rates data that contains 21 th of october at&amp;nbsp;&lt;SPAN style="background-color: transparent; color: #333333; cursor: text; display: inline; float: none; font-family: &amp;amp;quot; helevticaneue-light&amp;amp;quot;,&amp;amp;quot;helvetica neue&amp;amp;quot;,helvetica,arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 16.8px; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;market.IMP_EXCH&lt;/SPAN&gt; datatable. And trying to add 22 th of october to it by the code below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let data='/sasdata/input_22102019.xlsx';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC IMPORT OUT= EXCH&lt;BR /&gt;DATAFILE= &amp;amp;data&lt;BR /&gt;DBMS=xlsx REPLACE;&lt;BR /&gt;SHEET="fxrates";&amp;nbsp;/* fx rates data is in the fxrates sheet of the excel */&lt;BR /&gt;GETNAMES=YES;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data market.IMP_EXCH;&lt;BR /&gt;set EXCH&lt;BR /&gt;market.IMP_EXCH;&lt;BR /&gt;REPLACE;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but we got an error message like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR 457-185: The REPLACE statement is not valid on a data set that is opened for OUTPUT.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;the reason for adding a replace statement to code is preventing duplication in table&lt;/STRONG&gt;. does any one have any idea as a solution?&lt;/P&gt;</description>
    <pubDate>Wed, 23 Oct 2019 14:48:02 GMT</pubDate>
    <dc:creator>tansel</dc:creator>
    <dc:date>2019-10-23T14:48:02Z</dc:date>
    <item>
      <title>ERROR 457-185: The REPLACE statement is not valid on a data set that is opened for OUTPUT.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-457-185-The-REPLACE-statement-is-not-valid-on-a-data-set/m-p/598719#M172688</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We have an input excel that we read some data from multiple sources by vba and then importing some of it to the sas lib. We are aiming to import the new day data everyday and cumulate the data date by date in one table.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;for ex: we have a currency fx rates data that contains 21 th of october at&amp;nbsp;&lt;SPAN style="background-color: transparent; color: #333333; cursor: text; display: inline; float: none; font-family: &amp;amp;quot; helevticaneue-light&amp;amp;quot;,&amp;amp;quot;helvetica neue&amp;amp;quot;,helvetica,arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 16.8px; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;market.IMP_EXCH&lt;/SPAN&gt; datatable. And trying to add 22 th of october to it by the code below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let data='/sasdata/input_22102019.xlsx';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC IMPORT OUT= EXCH&lt;BR /&gt;DATAFILE= &amp;amp;data&lt;BR /&gt;DBMS=xlsx REPLACE;&lt;BR /&gt;SHEET="fxrates";&amp;nbsp;/* fx rates data is in the fxrates sheet of the excel */&lt;BR /&gt;GETNAMES=YES;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data market.IMP_EXCH;&lt;BR /&gt;set EXCH&lt;BR /&gt;market.IMP_EXCH;&lt;BR /&gt;REPLACE;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but we got an error message like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR 457-185: The REPLACE statement is not valid on a data set that is opened for OUTPUT.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;the reason for adding a replace statement to code is preventing duplication in table&lt;/STRONG&gt;. does any one have any idea as a solution?&lt;/P&gt;</description>
      <pubDate>Wed, 23 Oct 2019 14:48:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-457-185-The-REPLACE-statement-is-not-valid-on-a-data-set/m-p/598719#M172688</guid>
      <dc:creator>tansel</dc:creator>
      <dc:date>2019-10-23T14:48:02Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR 457-185: The REPLACE statement is not valid on a data set that is opened for OUTPUT.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-457-185-The-REPLACE-statement-is-not-valid-on-a-data-set/m-p/598723#M172690</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/286329"&gt;@tansel&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi everyone,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We have an input excel that we read some data from multiple sources by vba and then importing some of it to the sas lib. We are aiming to import the new day data everyday and cumulate the data date by date in one table.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;for ex: we have a currency fx rates data that contains 21 th of october at&amp;nbsp;&lt;SPAN style="text-align: left; color: rgb(51, 51, 51); text-transform: none; line-height: 16.8px; text-indent: 0px; letter-spacing: normal; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; word-spacing: 0px; float: none; display: inline; white-space: normal; cursor: text; orphans: 2; background-color: transparent; -webkit-text-stroke-width: 0px;"&gt;market.IMP_EXCH&lt;/SPAN&gt; datatable. And trying to add 22 th of october to it by the code below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let data='/sasdata/input_22102019.xlsx';&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC IMPORT OUT= EXCH&lt;BR /&gt;DATAFILE= &amp;amp;data&lt;BR /&gt;DBMS=xlsx REPLACE;&lt;BR /&gt;SHEET="fxrates";&amp;nbsp;/* fx rates data is in the fxrates sheet of the excel */&lt;BR /&gt;GETNAMES=YES;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data market.IMP_EXCH;&lt;BR /&gt;set EXCH&lt;BR /&gt;market.IMP_EXCH;&lt;BR /&gt;REPLACE;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but we got an error message like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ERROR 457-185: The REPLACE statement is not valid on a data set that is opened for OUTPUT.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;does any one have any idea as a solution?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Simple: Remove the Replace statement in the data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BTW you should be extremely cautious about using the :&lt;/P&gt;
&lt;P&gt;Data someset;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set someset&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;
&lt;P&gt;approach. If you have any data manipulation involved and make a logic error you have replaced the data set and may not be able to recover very easily.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would suggest Proc Append instead of that data step but Proc Import with XLSX are pretty poor about generating identical variable properties.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Oct 2019 14:34:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-457-185-The-REPLACE-statement-is-not-valid-on-a-data-set/m-p/598723#M172690</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-10-23T14:34:30Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR 457-185: The REPLACE statement is not valid on a data set that is opened for OUTPUT.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-457-185-The-REPLACE-statement-is-not-valid-on-a-data-set/m-p/598731#M172691</link>
      <description>&lt;P&gt;thanks for reply. i also try it and its working. but my concern is duplicating the data in table. (for example: inserting same day data for 2 or 3 times). have you got any suggestion for preventing it?&lt;/P&gt;</description>
      <pubDate>Wed, 23 Oct 2019 14:46:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-457-185-The-REPLACE-statement-is-not-valid-on-a-data-set/m-p/598731#M172691</guid>
      <dc:creator>tansel</dc:creator>
      <dc:date>2019-10-23T14:46:13Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR 457-185: The REPLACE statement is not valid on a data set that is opened for OUTPUT.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-457-185-The-REPLACE-statement-is-not-valid-on-a-data-set/m-p/598751#M172701</link>
      <description>Look into modify/update instead then. You need some way to identify that records may be duplicate, how would that be defined?&lt;BR /&gt;</description>
      <pubDate>Wed, 23 Oct 2019 15:23:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-457-185-The-REPLACE-statement-is-not-valid-on-a-data-set/m-p/598751#M172701</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-10-23T15:23:26Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR 457-185: The REPLACE statement is not valid on a data set that is opened for OUTPUT.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-457-185-The-REPLACE-statement-is-not-valid-on-a-data-set/m-p/598757#M172703</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One way to avoid duplications might be:&lt;/P&gt;
&lt;P&gt;In this code var1 var2 var3 are a generic list of sufficient variables to identify unique records.&lt;/P&gt;
&lt;PRE&gt;proc sort data=market.Imp_exch;
  by var1 var2 var3;
run;

proc sort data=exch;
   by var1 var2 var3;
run;


data market.imp_exch;
   update market.imp_exch
         exch
   ;
   by var1 var2 var3;
run;&lt;/PRE&gt;
&lt;P&gt;The market.imp_exch should only need to be sorted once unless you do something else to possibly change the order of variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Oct 2019 15:34:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-457-185-The-REPLACE-statement-is-not-valid-on-a-data-set/m-p/598757#M172703</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-10-23T15:34:51Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR 457-185: The REPLACE statement is not valid on a data set that is opened for OUTPUT.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-457-185-The-REPLACE-statement-is-not-valid-on-a-data-set/m-p/598954#M172812</link>
      <description>&lt;P&gt;first colomn of the current data is&amp;nbsp; as_of_date column. it can defined if "the first column of the next day's data" and "dates that are currently stored at the first column of current table" is matched. the picture below is a sample data from Sas database. &lt;SPAN style="display: inline !important; float: none; background-color: transparent; color: #333333; cursor: text; font-family: 'HelevticaNeue-light','Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;Just think &lt;/SPAN&gt;that I m trying to add the new day fx rates to this table everyday. (ex: a table with start 24/10/2019 for today). i dont want to duplicate it if there is already some data which has a 24/10/2019 date in the DATE column. this is the reason why i write a replace statement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;many thanks for your help&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Sample Data From Database table" style="width: 192px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/33378i314629367078CF98/image-size/large?v=v2&amp;amp;px=999" role="button" title="FXRATE.png" alt="Sample Data From Database table" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Sample Data From Database table&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Oct 2019 11:39:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-457-185-The-REPLACE-statement-is-not-valid-on-a-data-set/m-p/598954#M172812</guid>
      <dc:creator>tansel</dc:creator>
      <dc:date>2019-10-24T11:39:04Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR 457-185: The REPLACE statement is not valid on a data set that is opened for OUTPUT.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-457-185-The-REPLACE-statement-is-not-valid-on-a-data-set/m-p/599414#M173031</link>
      <description>That's not what REPLACE does, please read the documentation on what it actually does. It replaces the whole file, it doesn't pertain to specific records. UPDATE will apply to specific records.</description>
      <pubDate>Fri, 25 Oct 2019 17:16:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-457-185-The-REPLACE-statement-is-not-valid-on-a-data-set/m-p/599414#M173031</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-10-25T17:16:03Z</dc:date>
    </item>
  </channel>
</rss>

