<?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: Automate a  code using SAS macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Automate-a-code-using-SAS-macro/m-p/771332#M244753</link>
    <description>Thanks for your response.&lt;BR /&gt;&lt;BR /&gt;We have multiple sas programs which needs to be migrated which have libname statement as I mentioned in the above example. &lt;BR /&gt; we have to do this  many times for different different programs so to avoid manual work we need to automate the process.</description>
    <pubDate>Thu, 30 Sep 2021 10:02:51 GMT</pubDate>
    <dc:creator>Aexor</dc:creator>
    <dc:date>2021-09-30T10:02:51Z</dc:date>
    <item>
      <title>Automate a  code using SAS macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automate-a-code-using-SAS-macro/m-p/771326#M244740</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;I have few sample&amp;nbsp;&amp;nbsp;codes which needs to be migrated to new environment and i have&amp;nbsp; to replace old path with new.&lt;/P&gt;
&lt;TABLE width="1473px"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="393px"&gt;Library location&lt;/TD&gt;
&lt;TD width="385px"&gt;Old path&amp;nbsp;&lt;/TD&gt;
&lt;TD width="302px"&gt;New Path&lt;/TD&gt;
&lt;TD width="393px"&gt;Library location&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="393px"&gt;Libname libx "\\win907\A$\Data\Inside\one";&lt;/TD&gt;
&lt;TD width="385px"&gt;\\win907\A$\Data\Inside\one&lt;/TD&gt;
&lt;TD width="302px"&gt;\\open\C\XYZ\folderA\one&lt;/TD&gt;
&lt;TD width="393px"&gt;Libname libx "\\open\C\XYZ\folderA\one";&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="393px"&gt;Libname liby "\\win907\A$\Data\outside\two";&lt;/TD&gt;
&lt;TD width="385px"&gt;\\win907\A$\Data\outside\two&lt;/TD&gt;
&lt;TD width="302px"&gt;\\open\D\abc\folderB\two&lt;/TD&gt;
&lt;TD width="393px"&gt;Libname liby "&amp;nbsp;\\open\D\abc\folderB\two";&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="393px"&gt;LIBNAME libz&amp;nbsp; "\\win907\A$\Data\med\tag" ;&lt;/TD&gt;
&lt;TD width="385px"&gt;\\win907\A$\Data\med\tag&lt;/TD&gt;
&lt;TD width="302px"&gt;\\open\E\abc\folderC\tag&lt;/TD&gt;
&lt;TD width="393px"&gt;LIBNAME libz&amp;nbsp; "\\open\E\abc\folderC\tag" ;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="393px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="385px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="302px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="393px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp; I need to write a macro which will replace old path to new path and give new library location .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any suggestion or solution will be much appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Sep 2021 09:19:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automate-a-code-using-SAS-macro/m-p/771326#M244740</guid>
      <dc:creator>Aexor</dc:creator>
      <dc:date>2021-09-30T09:19:39Z</dc:date>
    </item>
    <item>
      <title>Re: Automate a  code using SAS macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automate-a-code-using-SAS-macro/m-p/771329#M244750</link>
      <description>&lt;P&gt;How many files do you have? Where are they?&lt;/P&gt;
&lt;P&gt;Can't you take the libname statements out of the individual programs and centralise them?&lt;/P&gt;</description>
      <pubDate>Thu, 30 Sep 2021 09:59:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automate-a-code-using-SAS-macro/m-p/771329#M244750</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-09-30T09:59:08Z</dc:date>
    </item>
    <item>
      <title>Re: Automate a  code using SAS macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automate-a-code-using-SAS-macro/m-p/771332#M244753</link>
      <description>Thanks for your response.&lt;BR /&gt;&lt;BR /&gt;We have multiple sas programs which needs to be migrated which have libname statement as I mentioned in the above example. &lt;BR /&gt; we have to do this  many times for different different programs so to avoid manual work we need to automate the process.</description>
      <pubDate>Thu, 30 Sep 2021 10:02:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automate-a-code-using-SAS-macro/m-p/771332#M244753</guid>
      <dc:creator>Aexor</dc:creator>
      <dc:date>2021-09-30T10:02:51Z</dc:date>
    </item>
    <item>
      <title>Re: Automate a  code using SAS macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automate-a-code-using-SAS-macro/m-p/771336#M244757</link>
      <description>&lt;P&gt;You should grab the opportunity and centralize the library definitions, either in an autoexec file or in SAS metadata. Programs should not have library definitions within them if those libraries are used in the same way (same libref and physical path) across different programs.&lt;/P&gt;
&lt;P&gt;This will be a strong investment into your own future, instead of keeping the debt in time spent to maintain the codes.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Sep 2021 10:28:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automate-a-code-using-SAS-macro/m-p/771336#M244757</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-09-30T10:28:39Z</dc:date>
    </item>
    <item>
      <title>Re: Automate a  code using SAS macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automate-a-code-using-SAS-macro/m-p/771346#M244761</link>
      <description>&lt;P&gt;Agreeing with the above.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you write LIBNAME statements in every piece of code, when the location of the libref changes, then you have to change every piece of code. Putting this in an AUTOEXEC makes handling this situation much much simpler, you only have to change the location in one place.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In my autoexec, I use (something like) this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let pers = g:\myserver\mydepartment\MillerP;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And then in code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname proj1 "&amp;amp;pers\proj1";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and if the location of my server files ever changes, I just change the autoexec and all code immediately uses the new location.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Similarly, you can do the same for databases, you put the proper libname in a simple macro in the AUTOEXEC and then always call the libname statement via a simple macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro db1;
libname db1 odbc dsn=AAAAA schema=dbo user=BBBBBB password=xxxxxx;
%mend db1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and then in code where I want to link to this database&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%db1&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and again, if the libname ever changes, you just change the autoexec, not the actual code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A long time ago, before I did this, I had to write SAS code that reads every .sas file and parses the code and looks for the old server location and then changes the text of the .sas file to contain the new server location. I no longer have this code as it was written when I worked at a different employer, but it can be done. Nevertheless, I think you can see that not having to do this when the server changes is a better solution in the long run.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Sep 2021 11:45:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automate-a-code-using-SAS-macro/m-p/771346#M244761</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-09-30T11:45:20Z</dc:date>
    </item>
    <item>
      <title>Re: Automate a  code using SAS macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automate-a-code-using-SAS-macro/m-p/771354#M244765</link>
      <description>&lt;P&gt;Is the issue just 3 librefs with constant paths?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro libs(version);
%if %qupcase(&amp;amp;version)=OLD %then %do;
Libname libx "\\win907\A$\Data\Inside\one";	
Libname liby "\\win907\A$\Data\outside\two";	
LIBNAME libz  "\\win907\A$\Data\med\tag" ;	
%end;
%else %do;
Libname libx "\\open\C\XYZ\folderA\one";
Libname liby " \\open\D\abc\folderB\two";
LIBNAME libz  "\\open\E\abc\folderC\tag" ;
%end;
%mend;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 30 Sep 2021 12:44:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automate-a-code-using-SAS-macro/m-p/771354#M244765</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-09-30T12:44:27Z</dc:date>
    </item>
    <item>
      <title>Re: Automate a  code using SAS macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automate-a-code-using-SAS-macro/m-p/771359#M244768</link>
      <description>Thanks I got your point . will try to implement as suggested.&lt;BR /&gt;&lt;BR /&gt;Also I am a bit curious on macro side too. can you suggest approach if  there is any possibility of pattern matching of the libanme statemnet with the new libname name and then replacing the path</description>
      <pubDate>Thu, 30 Sep 2021 12:56:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automate-a-code-using-SAS-macro/m-p/771359#M244768</guid>
      <dc:creator>Aexor</dc:creator>
      <dc:date>2021-09-30T12:56:42Z</dc:date>
    </item>
    <item>
      <title>Re: Automate a  code using SAS macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automate-a-code-using-SAS-macro/m-p/771360#M244769</link>
      <description>&lt;P&gt;Agree with comments from others about centralizing the definitions etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That said, since .sas files are just text files, it looks like for a "quick-and-dirty" approach you could use a text editor to find and replace the old directory paths with the new paths. Most editors (Notepad++, Ultra-Edit, etc.) make it easy to do that for all *.sas files in a specified directory (and subdirectories).&amp;nbsp; You'll want to make a back up your code first (in my first year of coding, I once accidentally removed ALL the CR/LF in my .sas programs for one project, because I clicked "replace in files" rather than "replace in the currently open file".&amp;nbsp; : )&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;While you can use SAS to edit text files, in this cases it's probably easier to use a text editor to edit text files.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But as others have said, if you have time, better to refactor this to pull out the library definitions or path definitions...&lt;/P&gt;</description>
      <pubDate>Thu, 30 Sep 2021 12:58:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automate-a-code-using-SAS-macro/m-p/771360#M244769</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2021-09-30T12:58:04Z</dc:date>
    </item>
    <item>
      <title>Re: Automate a  code using SAS macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automate-a-code-using-SAS-macro/m-p/771371#M244773</link>
      <description>&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/Search-for-a-text-from-diffrent-directories/td-p/321615" target="_self"&gt;Next link&lt;/A&gt; conains a macro program which enables search text files (.sas, .log etc.) in different folders for a given string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It can be addapted to seracch for any string given in a list of strings (old paths)&lt;/P&gt;
&lt;P&gt;in a loop. (for example - generating the code and submiting it by call execute);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I do not suggest to replace strings automatically.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Sep 2021 13:45:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automate-a-code-using-SAS-macro/m-p/771371#M244773</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2021-09-30T13:45:05Z</dc:date>
    </item>
    <item>
      <title>Re: Automate a  code using SAS macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automate-a-code-using-SAS-macro/m-p/771382#M244777</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19879"&gt;@Quentin&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That said, since .sas files are just text files, it looks like for a "quick-and-dirty" approach you could use a text editor to find and replace the old directory paths with the new paths. Most editors (Notepad++, Ultra-Edit, etc.) make it easy to do that for all *.sas files in a specified directory (and subdirectories).&amp;nbsp; You'll want to make a back up your code first (in my first year of coding, I once accidentally removed ALL the CR/LF in my .sas programs for one project, because I clicked "replace in files" rather than "replace in the currently open file".&amp;nbsp; : )&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;While you can use SAS to edit text files, in this cases it's probably easier to use a text editor to edit text files.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Great point, Notepad++ and other programs can make bulk find-and-replace operations.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Sep 2021 14:16:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automate-a-code-using-SAS-macro/m-p/771382#M244777</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-09-30T14:16:56Z</dc:date>
    </item>
    <item>
      <title>Re: Automate a  code using SAS macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automate-a-code-using-SAS-macro/m-p/771538#M244854</link>
      <description>Thank you!  I will try &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Fri, 01 Oct 2021 04:31:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automate-a-code-using-SAS-macro/m-p/771538#M244854</guid>
      <dc:creator>Aexor</dc:creator>
      <dc:date>2021-10-01T04:31:04Z</dc:date>
    </item>
    <item>
      <title>Re: Automate a  code using SAS macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automate-a-code-using-SAS-macro/m-p/771539#M244855</link>
      <description>No, I have many .</description>
      <pubDate>Fri, 01 Oct 2021 04:33:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automate-a-code-using-SAS-macro/m-p/771539#M244855</guid>
      <dc:creator>Aexor</dc:creator>
      <dc:date>2021-10-01T04:33:11Z</dc:date>
    </item>
    <item>
      <title>Re: Automate a  code using SAS macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automate-a-code-using-SAS-macro/m-p/771546#M244859</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/327170"&gt;@Aexor&lt;/a&gt;&amp;nbsp;To use the opportunity for a clean-up as already suggested is certainly a very good idea. In case that's not possible then below should give you a start.&lt;/P&gt;
&lt;P&gt;Make sure you first run this code with &amp;amp;for_real=N This will create a report of what would get changed without changing/creating new files.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code applies for any .sas file that resides in a folder or sub-folder that you provide in below code section.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1633076465850.png" style="width: 208px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/64291i03C70D99DADE13FA/image-dimensions/208x83?v=v2" width="208" height="83" role="button" title="Patrick_0-1633076465850.png" alt="Patrick_0-1633076465850.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's always worth to search the communities and the SAS documentation as many questions have been asked and resolved before.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And here the full code. As long as you don't run with&amp;nbsp;&amp;amp;for_real=N this code will not write anything back to disk.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*%let for_real=Y;*/  /* creates file with changes: &amp;lt;filename&amp;gt;.sas.CHANGED */
%let for_real=N;      /* creates and prints a table with changes but doesn't create the CHANGED file */

/** directory listing **/
/* https://communities.sas.com/t5/SAS-Programming/List-of-Files-in-Directory-and-Subdirectories-with-File/m-p/696059 */
data filelist;
  length dname thisFile $256 dir level 8;
  input dname;
  retain thisFile ' ' level 0 dir 1;
datalines4;
c:\temp
;;;;

data filelist;
  modify filelist;
  rc1=filename('tmp',catx('/',dname,thisFile));
  rc2=dopen('tmp');
  dir = not not rc2;
  if not dir then do;
    fid=fopen('tmp','i',0,'b');
    fid=fclose(fid);
  end;
  else do;
    dname=catx('/',dname,thisFile);
    thisFile=' ';
  end;
  replace;
  if dir;
  level=level+1;
  do i=1 to dnum(rc2);
    thisFile=dread(rc2,i);
    if upcase(scan(thisFile,-1,'.'))='SAS' then output;
  end;
  rc3=dclose(rc2);
run;

/** list of paths to replace **/
data paths;
  infile datalines truncover dlm='|';
  input oldPath :$1000. newPath :$1000.;
  datalines;
\\win907\A$\Data\Inside\one|\\open\C\XYZ\folderA\one
\\win907\A$\Data\outside\two|\\open\D\abc\folderB\two
;

/** search and replace paths in files from filelist **/
/*  Example 5: reading from multiple input files: 
/*    https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/n1rill4udj0tfun1fvce3j401plo.htm#n1x9joj5qbfkjyn1kqtm7joru0qb */
data _null_;
  if _n_=1 then
    do;
      /* hash lookup table for old/new paths */
      length hkey $1;
      retain key '1';
      dcl hash h1(multidata:'y');
      h1.defineKey('hkey');
      h1.defineData('oldPath','newPath');
      h1.defineDone();
      do until(done);
        set paths end=done;
        rc=h1.add();
      end;
      done=0;
      /* hash table to collect rows with changes */
      length row 8 lineOrig lineChanged $256;
      dcl hash chng(multidata:'y',ordered:'y');
      chng.defineKey('dname','thisFile','row');
      chng.defineData('dname','thisFile','row','lineOrig','lineChanged');
      chng.defineDone();
    end;

  set filelist end=last;
  if not missing(thisFile);
  length fileloc $1100;
  fileloc=catx('\',dname,thisFile);

  infile myfile filevar=fileloc end=done lrecl=512 line=row; 

  do while(not done);
    input;
    /* search and replace paths */
    /* https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lrcon/p1f92kngyuurnln120e2na45022k.htm */
    do while (h1.do_over() = 0);
      startPos=find(_infile_,strip(oldPath),'i');
      if startPos&amp;gt;0 then
        do;
          lineOrig=_infile_;
          _infile_=cats(substrn(_infile_,1,startPos-1),newPath,substrn(_infile_,startPos+length(oldPath)));
          lineChanged=_infile_;
          /* collect changes */
          rc=chng.add();
        end;
    end;

    /* write changes to &amp;lt;filename&amp;gt;.sas.CHANGED */
    %macro for_real(for_real=N);
    %if &amp;amp;for_real=Y %then
      %do;
        outfile=cats(fileloc,'.CHANGED'); 
        file dummy filevar=outfile;
        len=length(_infile_);
        put _infile_ $varying. len;
      %end;
    %mend;
    %for_real(for_real=&amp;amp;for_real);
  end;

  if last then
    do;
      rc=chng.output(dataset:'work.changes');
    end;

run;

title 'Rows with Changes';
proc print data=work.changes;
run;
title;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Oct 2021 15:02:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automate-a-code-using-SAS-macro/m-p/771546#M244859</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-10-01T15:02:47Z</dc:date>
    </item>
    <item>
      <title>Re: Automate a  code using SAS macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automate-a-code-using-SAS-macro/m-p/771560#M244873</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/327170"&gt;@Aexor&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;No, I have many .&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Then explain in more detail what your actual question is.&lt;/P&gt;
&lt;P&gt;You made it sound like you wanted something that would modify an existing libref that has already been defined.&amp;nbsp; If that is true why?&amp;nbsp; Why not just define it right to begin with?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you saying you need to modify the source code in a lot of program files that have hardcoded paths?&lt;/P&gt;
&lt;P&gt;If so then to make the code more flexible you might replace the LIBNAME statements with a call to a macro, but you would need to explain in much more detail whether there is any pattern to the directories you need to point the librefs to.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example if your directory structure creates a parallel locations to be used by each separate project you might create a macro where the user specifies the project name and the librefs are created automatically.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro librefs(project);
%let topnode=/myapplication;

libname raw "&amp;amp;topnode/&amp;amp;project/raw" access=readonly;
libname standard "&amp;amp;topnode/&amp;amp;project/standard";

%mend librefs;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 01 Oct 2021 12:08:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automate-a-code-using-SAS-macro/m-p/771560#M244873</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-10-01T12:08:39Z</dc:date>
    </item>
  </channel>
</rss>

