<?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: replace sas code automatically within sas programs in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/replace-sas-code-automatically-within-sas-programs/m-p/440081#M109876</link>
    <description>&lt;P&gt;Yes, I have written code in a previous job that does this. Basically, you read each line of text from the file, then you write each line of text to a new file with any changes that are necessary.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the long run, a better solution is to create macro variables that you set in your autoexec file, that define file or server locations such as&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let myfilelocation = y:\networkfolder1\networkfolder2;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then in your SAS code, you use &amp;amp;myfilelocation instead of y:\networkfolder1\networkfolder2. If the location of the files/server ever changes, you don't have to change the SAS code, you just make one change to the autoexec file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 25 Feb 2018 22:05:34 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2018-02-25T22:05:34Z</dc:date>
    <item>
      <title>replace sas code automatically within sas programs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replace-sas-code-automatically-within-sas-programs/m-p/440075#M109874</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I have a question which I'm not sure whether this is actually possible.&lt;/P&gt;&lt;P&gt;Let's say you have over a 1000 sas programs stored on a network drive spread over many different folders.&lt;/P&gt;&lt;P&gt;And you have to change a fixed thing within these programs, f.i.&lt;/P&gt;&lt;P&gt;libname testlib z:\networkfolder1\networkfolder2&lt;/P&gt;&lt;P&gt;should be :&lt;/P&gt;&lt;P&gt;libname testlib y:\networkfolder1\networkfolder2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is this possible from another SAS program somehow without opening every individual program ?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;B&lt;/P&gt;</description>
      <pubDate>Sun, 25 Feb 2018 20:56:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replace-sas-code-automatically-within-sas-programs/m-p/440075#M109874</guid>
      <dc:creator>Billybob73</dc:creator>
      <dc:date>2018-02-25T20:56:20Z</dc:date>
    </item>
    <item>
      <title>Re: replace sas code automatically within sas programs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replace-sas-code-automatically-within-sas-programs/m-p/440081#M109876</link>
      <description>&lt;P&gt;Yes, I have written code in a previous job that does this. Basically, you read each line of text from the file, then you write each line of text to a new file with any changes that are necessary.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the long run, a better solution is to create macro variables that you set in your autoexec file, that define file or server locations such as&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let myfilelocation = y:\networkfolder1\networkfolder2;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then in your SAS code, you use &amp;amp;myfilelocation instead of y:\networkfolder1\networkfolder2. If the location of the files/server ever changes, you don't have to change the SAS code, you just make one change to the autoexec file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 25 Feb 2018 22:05:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replace-sas-code-automatically-within-sas-programs/m-p/440081#M109876</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-02-25T22:05:34Z</dc:date>
    </item>
    <item>
      <title>Re: replace sas code automatically within sas programs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replace-sas-code-automatically-within-sas-programs/m-p/440088#M109877</link>
      <description>&lt;P&gt;This gets asked occasionally on here.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;suggested, removing the libname is a better method in the long run so you never have to repeat this.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/Base-SAS-Programming/Searching-SAS-code-for-keywords/m-p/390472#M93671" target="_blank"&gt;https://communities.sas.com/t5/Base-SAS-Programming/Searching-SAS-code-for-keywords/m-p/390472#M93671&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 25 Feb 2018 22:52:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replace-sas-code-automatically-within-sas-programs/m-p/440088#M109877</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-02-25T22:52:20Z</dc:date>
    </item>
    <item>
      <title>Re: replace sas code automatically within sas programs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replace-sas-code-automatically-within-sas-programs/m-p/440094#M109880</link>
      <description>&lt;P&gt;It's for exactly this scenario that shared SAS libraries should be defined and stored in SAS metadata via SAS Management Console removing the need to store them in programs at all. Of course this is only an option if you have a remote SAS server that is metadata enabled. Otherwise the&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;solution is good.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suggest you consider removing the shared libnames from your SAS programs and replacing them with metadata-defined ones. That means if you need to change them in the future you only need to do it in one place - SAS&amp;nbsp;&lt;SPAN&gt;Management Console.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 25 Feb 2018 23:56:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replace-sas-code-automatically-within-sas-programs/m-p/440094#M109880</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2018-02-25T23:56:49Z</dc:date>
    </item>
    <item>
      <title>Re: replace sas code automatically within sas programs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replace-sas-code-automatically-within-sas-programs/m-p/440666#M110136</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;These aren't the answers I was looking for. The library assignment was just an example.&lt;/P&gt;&lt;P&gt;Let's say I'd like to replace any fixed thing that is in a lot of files.&lt;/P&gt;&lt;P&gt;How would I proceed if I had like a 1000 programs.&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;B&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2018 21:18:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replace-sas-code-automatically-within-sas-programs/m-p/440666#M110136</guid>
      <dc:creator>Billybob73</dc:creator>
      <dc:date>2018-02-27T21:18:15Z</dc:date>
    </item>
    <item>
      <title>Re: replace sas code automatically within sas programs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replace-sas-code-automatically-within-sas-programs/m-p/440669#M110138</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/172904"&gt;@Billybob73&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;These aren't the answers I was looking for. The library assignment was just an example.&lt;/P&gt;
&lt;P&gt;Let's say I'd like to replace any fixed thing that is in a lot of files.&lt;/P&gt;
&lt;P&gt;How would I proceed if I had like a 1000 programs.&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;
&lt;P&gt;B&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Write a program to modify the files. SAS programs are just text files.&lt;/P&gt;
&lt;P&gt;What we did years ago was make a program that would process one file.&amp;nbsp; It would look for particular patterns (like LIBNAME, FILE, INFILE statements).&amp;nbsp; It would convert the original line to a comment and generate a new line.&lt;/P&gt;
&lt;P&gt;Users could then manually check and save the results.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To run it for a 1000 programs just use another program to generate the list of files to process and then call the first program for each file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can do it all in SAS or do it all with some other tool.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2018 21:38:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replace-sas-code-automatically-within-sas-programs/m-p/440669#M110138</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-02-27T21:38:15Z</dc:date>
    </item>
  </channel>
</rss>

