<?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: How would I change a libname statement to “read only”  and prevent tables from getting overwritten if I run the program again? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-would-I-change-a-libname-statement-to-read-only-and-prevent/m-p/151909#M29916</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I used two macro variables.&amp;nbsp; When I call the program, and it is the first running, I make my library name the 'update' library.&amp;nbsp; When I am re-running the code, I make my library the read only library.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(I did not check this for syntax and misspellings)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let rerun=no;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;libname writeover 'my\writable\table\folder\location';&lt;/P&gt;&lt;P&gt;libname readonly 'my\readonly\table\folder\location';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro rerun;&lt;/P&gt;&lt;P&gt;%if &amp;amp;rerun=no %then %do;&lt;/P&gt;&lt;P&gt;%let libnm=writeover;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%else %if rerun=yes %then %do;&lt;/P&gt;&lt;P&gt;%libnm=readonly;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%else %do;&lt;/P&gt;&lt;P&gt;%let libnm=work;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%rerun;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data &amp;amp;libnm..dataout;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set writable.datain;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 06 Aug 2014 17:18:56 GMT</pubDate>
    <dc:creator>jwillis</dc:creator>
    <dc:date>2014-08-06T17:18:56Z</dc:date>
    <item>
      <title>How would I change a libname statement to “read only”  and prevent tables from getting overwritten if I run the program again?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-would-I-change-a-libname-statement-to-read-only-and-prevent/m-p/151907#M29914</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello! I’m still pretty new to SAS. I was wondering how would I change the libname statement to “read only” after it creates the tables in a program and prevent it from overwriting existing tables if I run the program again?&amp;nbsp; Also, if the program gets ran again, I would like to prevent it from overwriting existing tables.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried running the libname &lt;STRONG&gt;without&lt;/STRONG&gt; “&lt;SPAN style="background: white; color: blue;"&gt;ACCESS&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black;"&gt;=READONLY” &lt;/SPAN&gt;in the beginning of the program and including the libname again &lt;STRONG&gt;with&lt;/STRONG&gt; “&lt;SPAN style="background: white; color: blue;"&gt;ACCESS&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black;"&gt;=READONLY” at the end of the program. It&amp;nbsp; doesn’t prevent my tables from getting overwritten if the program gets ran again.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue;"&gt;LIBNAME&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt; X &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: purple;"&gt;"&amp;amp;UDIR\SAS TABLES\&amp;amp;MP1DB_YYMMN6"&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt;My Tables in Program&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue;"&gt;LIBNAME&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt; X &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: purple;"&gt;"&amp;amp;UDIR\SAS TABLES\&amp;amp;MP1DB_YYMMN6"&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue;"&gt;ACCESS&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt;=READONLY;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; background: white; color: black;"&gt;Thanks so much!&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Aug 2014 16:45:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-would-I-change-a-libname-statement-to-read-only-and-prevent/m-p/151907#M29914</guid>
      <dc:creator>mcrum1</dc:creator>
      <dc:date>2014-08-06T16:45:58Z</dc:date>
    </item>
    <item>
      <title>Re: How would I change a libname statement to “read only”  and prevent tables from getting overwritten if I run the program again?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-would-I-change-a-libname-statement-to-read-only-and-prevent/m-p/151908#M29915</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try using dataset option (REPLACE=NO) in the step that may overwrite the table. - PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Aug 2014 17:08:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-would-I-change-a-libname-statement-to-read-only-and-prevent/m-p/151908#M29915</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2014-08-06T17:08:55Z</dc:date>
    </item>
    <item>
      <title>Re: How would I change a libname statement to “read only”  and prevent tables from getting overwritten if I run the program again?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-would-I-change-a-libname-statement-to-read-only-and-prevent/m-p/151909#M29916</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I used two macro variables.&amp;nbsp; When I call the program, and it is the first running, I make my library name the 'update' library.&amp;nbsp; When I am re-running the code, I make my library the read only library.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(I did not check this for syntax and misspellings)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let rerun=no;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;libname writeover 'my\writable\table\folder\location';&lt;/P&gt;&lt;P&gt;libname readonly 'my\readonly\table\folder\location';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro rerun;&lt;/P&gt;&lt;P&gt;%if &amp;amp;rerun=no %then %do;&lt;/P&gt;&lt;P&gt;%let libnm=writeover;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%else %if rerun=yes %then %do;&lt;/P&gt;&lt;P&gt;%libnm=readonly;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%else %do;&lt;/P&gt;&lt;P&gt;%let libnm=work;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%rerun;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data &amp;amp;libnm..dataout;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set writable.datain;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Aug 2014 17:18:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-would-I-change-a-libname-statement-to-read-only-and-prevent/m-p/151909#M29916</guid>
      <dc:creator>jwillis</dc:creator>
      <dc:date>2014-08-06T17:18:56Z</dc:date>
    </item>
    <item>
      <title>Re: How would I change a libname statement to “read only”  and prevent tables from getting overwritten if I run the program again?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-would-I-change-a-libname-statement-to-read-only-and-prevent/m-p/151910#M29917</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just a guess here ... that sometimes the reason this question comes up relates to having blown away a data set by leaving out a semicolon on the DATA statement.&amp;nbsp; This program, for example, replaces a good data set with garbage:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data perm.old&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set perm.old;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; total = 2 * pints;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To prevent this from happening, the DATASTMTCHK option can restrict what is a valid data set name.&amp;nbsp; For example, it can prevent the above DATA step from running by classifying SET as an invalid data set name.&amp;nbsp; The possible values include COREKEYWORDS (such as SET, MERGE, UPDATE), ALLKEYWORDS (adds DATA step statements as invalid data set names) and NONE (no restrictions on data set names).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Aug 2014 17:22:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-would-I-change-a-libname-statement-to-read-only-and-prevent/m-p/151910#M29917</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2014-08-06T17:22:48Z</dc:date>
    </item>
    <item>
      <title>Re: How would I change a libname statement to “read only”  and prevent tables from getting overwritten if I run the program again?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-would-I-change-a-libname-statement-to-read-only-and-prevent/m-p/151911#M29918</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;if you are running the program a second time then yes, it will overwrite the dataset.&lt;/P&gt;&lt;P&gt;what you have supplied as your code is similar to below. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;libname x "d:\temp";&lt;/P&gt;&lt;P&gt;data x.one;&lt;/P&gt;&lt;P&gt;&amp;nbsp; today=today();&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* this will create the dataset */&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;libname x clear;&lt;/P&gt;&lt;P&gt;libname x "d:\temp" access=readonly;&lt;/P&gt;&lt;P&gt;data x.one;&lt;/P&gt;&lt;P&gt;&amp;nbsp; today=today()-1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; format today date9.;&amp;nbsp;&amp;nbsp;&amp;nbsp; this will NOT overwrite the dataset due to the ACCESS=readonly */&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you rerun the code the first one will again, overwrite your dataset.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Aug 2014 18:14:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-would-I-change-a-libname-statement-to-read-only-and-prevent/m-p/151911#M29918</guid>
      <dc:creator>SASBob</dc:creator>
      <dc:date>2014-08-06T18:14:09Z</dc:date>
    </item>
    <item>
      <title>Re: How would I change a libname statement to “read only”  and prevent tables from getting overwritten if I run the program again?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-would-I-change-a-libname-statement-to-read-only-and-prevent/m-p/151912#M29919</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you are going to re-run the program then the program itself needs to be smart enough not to overwrite (or whatever logic you want).&lt;/P&gt;&lt;P&gt;In general I have found it is useful to separate derived data programs (or ETL) from analysis programs.&lt;/P&gt;&lt;P&gt;One way to help eliminate confusion is to force the program that wants to write to use a different LIBREF.&lt;/P&gt;&lt;P&gt;So you might have a standard&lt;/P&gt;&lt;P&gt;LIBNAME MYDATA '.....' ACCESS=READONLY;&lt;/P&gt;&lt;P&gt;at the top of all of the programs.&amp;nbsp; And then the programs that need to create new data in the library might create a new libref.&lt;/P&gt;&lt;P&gt;LIBNAME WMYDATA '....' ;&lt;/P&gt;&lt;P&gt;data wmydata.new ; &lt;/P&gt;&lt;P&gt; ...&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;libname WMYDATA clear ;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Aug 2014 19:09:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-would-I-change-a-libname-statement-to-read-only-and-prevent/m-p/151912#M29919</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-08-06T19:09:02Z</dc:date>
    </item>
    <item>
      <title>Re: How would I change a libname statement to “read only”  and prevent tables from getting overwritten if I run the program again?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-would-I-change-a-libname-statement-to-read-only-and-prevent/m-p/151913#M29920</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tom,&lt;/P&gt;&lt;P&gt;&amp;nbsp; after I looking at my response, I don't think I could have been any more vague. thank you for putting into words what I was trying to say &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Bob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Aug 2014 19:18:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-would-I-change-a-libname-statement-to-read-only-and-prevent/m-p/151913#M29920</guid>
      <dc:creator>SASBob</dc:creator>
      <dc:date>2014-08-06T19:18:59Z</dc:date>
    </item>
    <item>
      <title>Re: How would I change a libname statement to “read only”  and prevent tables from getting overwritten if I run the program again?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-would-I-change-a-libname-statement-to-read-only-and-prevent/m-p/151914#M29921</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;1) make a view for each and everyone of tables.&lt;/P&gt;&lt;P&gt;2) add dataset's option&amp;nbsp;&amp;nbsp; alter=&amp;nbsp;&amp;nbsp; to avoid being overwrite problem .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Xia Keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Aug 2014 13:17:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-would-I-change-a-libname-statement-to-read-only-and-prevent/m-p/151914#M29921</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2014-08-07T13:17:46Z</dc:date>
    </item>
  </channel>
</rss>

