<?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 to Update Multiple Codes at the Same Time? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-Update-Multiple-Codes-at-the-Same-Time/m-p/681914#M206351</link>
    <description>&lt;P&gt;You can create a macro where the path name is an argument to the macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you provide the example code as text rather pasted into the window that appears when you click on the "running man" icon, rather than as a screen capture, we can show you how to create a macro with this code. (It's never useful to provide code in a screen capture)&lt;/P&gt;</description>
    <pubDate>Sun, 06 Sep 2020 21:43:48 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2020-09-06T21:43:48Z</dc:date>
    <item>
      <title>How to Update Multiple Codes at the Same Time?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Update-Multiple-Codes-at-the-Same-Time/m-p/681911#M206349</link>
      <description>&lt;P&gt;Hello everybody,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have 5 codes doing the same job, the only difference between these codes is that they write to different paths. Here is a thing that forces me, when I change one of the codes, then I need to do it for all of the other codes too. This causes me both margin of error and a waste of time for me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So here, I am looking for an automatic structure that can solve my issue.&lt;BR /&gt;Let's assume, I have five sample codes and they write to different directories as below;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="WhatsApp Image 2020-09-07 at 00.08.27.jpeg" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/49044i1481A50027C073AA/image-size/large?v=v2&amp;amp;px=999" role="button" title="WhatsApp Image 2020-09-07 at 00.08.27.jpeg" alt="WhatsApp Image 2020-09-07 at 00.08.27.jpeg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;If I want to change something in any of them, I want all of them to be affected at the same time. How can I build that structure?&lt;/P&gt;</description>
      <pubDate>Sun, 06 Sep 2020 21:12:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Update-Multiple-Codes-at-the-Same-Time/m-p/681911#M206349</guid>
      <dc:creator>tarikbirinci1</dc:creator>
      <dc:date>2020-09-06T21:12:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to Update Multiple Codes at the Same Time?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Update-Multiple-Codes-at-the-Same-Time/m-p/681914#M206351</link>
      <description>&lt;P&gt;You can create a macro where the path name is an argument to the macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you provide the example code as text rather pasted into the window that appears when you click on the "running man" icon, rather than as a screen capture, we can show you how to create a macro with this code. (It's never useful to provide code in a screen capture)&lt;/P&gt;</description>
      <pubDate>Sun, 06 Sep 2020 21:43:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Update-Multiple-Codes-at-the-Same-Time/m-p/681914#M206351</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-09-06T21:43:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to Update Multiple Codes at the Same Time?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Update-Multiple-Codes-at-the-Same-Time/m-p/681950#M206365</link>
      <description>&lt;P&gt;What would the change be? You still need 5 paths don't you?&lt;/P&gt;</description>
      <pubDate>Mon, 07 Sep 2020 04:52:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Update-Multiple-Codes-at-the-Same-Time/m-p/681950#M206365</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-09-07T04:52:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to Update Multiple Codes at the Same Time?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Update-Multiple-Codes-at-the-Same-Time/m-p/681960#M206371</link>
      <description>&lt;P&gt;Here is code as text:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA HAVE;
LENGTH NAME $ 32 ID 8;
INFILE DATALINES MISSOVER;
INPUT NAME ID;
DATALINES;
JOHN 1
JACK 2
EMILY 3
BLAKE 4
ROBIN 5
BRAD 6
;

/*CODE 1*/

LIBNAME WANT "C:\OUT1";

DATA WANT;
SET HAVE;

RUN;

/*CODE 2*/

LIBNAME WANT "C:\OUT2";


DATA WANT;
SET HAVE;

RUN;

/*CODE 3*/

LIBNAME WANT "C:\OUT3";


DATA WANT;
SET HAVE;

RUN;

/*CODE 4*/

LIBNAME WANT "C:\OUT4";


DATA WANT;
SET HAVE;

RUN;

/*CODE 5*/

LIBNAME WANT "C:\OUT5";


DATA WANT;
SET HAVE;

RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thank you for your support.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Sep 2020 06:51:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Update-Multiple-Codes-at-the-Same-Time/m-p/681960#M206371</guid>
      <dc:creator>tarikbirinci1</dc:creator>
      <dc:date>2020-09-07T06:51:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to Update Multiple Codes at the Same Time?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Update-Multiple-Codes-at-the-Same-Time/m-p/681963#M206373</link>
      <description>&lt;P&gt;I doubt that the code does what you expect it to do.The statement "data want;" creates the datasets "want" in the work library, not in the library "want".&lt;/P&gt;</description>
      <pubDate>Mon, 07 Sep 2020 07:03:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Update-Multiple-Codes-at-the-Same-Time/m-p/681963#M206373</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2020-09-07T07:03:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to Update Multiple Codes at the Same Time?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Update-Multiple-Codes-at-the-Same-Time/m-p/681966#M206374</link>
      <description>&lt;DIV&gt;&lt;P&gt;&lt;SPAN&gt;I forgot to type Out1 libnames for every Want data set. I have edited the code as below. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Yes, there should be 5 different paths but there should be only one code.&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*CODE 1*/

LIBNAME OUT1 "C:\OUT1";

DATA OUT1.WANT;
SET HAVE;

RUN;

/*CODE 2*/

LIBNAME OUT2 "C:\OUT2";

DATA OUT2.WANT;
SET HAVE;

RUN;

/*CODE 3*/

LIBNAME OUT3 "C:\OUT3";

DATA OUT3.WANT;
SET HAVE;

RUN;

/*CODE 4*/

LIBNAME OUT4 "C:\OUT4";

DATA OUT4.WANT;
SET HAVE;

RUN;

/*CODE 5*/

LIBNAME OUT5 "C:\OUT5";

DATA OUT5.WANT;
SET HAVE;

RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;DIV&gt;Maybe someting like the following structure, but I am not sure about how to do it well.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%MACRO PATH(LIBNAME);

%IF &amp;amp;LIBNAME.= OUT1 %THEN %DO;

LIBNAME OUT1 "C:\OUT1";

%END;

%ELSE %IF &amp;amp;LIBNAME.= OUT2 %THEN %DO;

LIBNAME OUT2 "C:\OUT2";

%END;

%ELSE %IF &amp;amp;LIBNAME.= OUT3 %THEN %DO;

LIBNAME OUT3 "C:\OUT3";

%END;

%ELSE %IF &amp;amp;LIBNAME.= OUT4 %THEN %DO;

LIBNAME OUT4 "C:\OUT4";

%END;

%ELSE %IF &amp;amp;LIBNAME.= OUT5 %THEN %DO;

LIBNAME OUT5 "C:\OUT5";

%END;

%MEND PATH;
%PATH(OUT1);
%PATH(OUT2);
%PATH(OUT3);
%PATH(OUT4);
%PATH(OUT5);&lt;BR /&gt;&lt;BR /&gt;/* &amp;amp;libname macro variable should be dynamic but I couldn't figure out how to do it */&lt;BR /&gt;&lt;BR /&gt;LIBNAME &amp;amp;libname "C:\&amp;amp;libname";

DATA &amp;amp;libname.WANT;
SET HAVE;

RUN;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 07 Sep 2020 07:57:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Update-Multiple-Codes-at-the-Same-Time/m-p/681966#M206374</guid>
      <dc:creator>tarikbirinci1</dc:creator>
      <dc:date>2020-09-07T07:57:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to Update Multiple Codes at the Same Time?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Update-Multiple-Codes-at-the-Same-Time/m-p/681977#M206381</link>
      <description>&lt;P&gt;If you use the LIBNAME function in a macro, you can make it very simple:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro multiout(paths,dsname=want,delim=%str( ));
  %local i rc;
  %do i=1 %to %sysfunc(countw(&amp;amp;paths,&amp;amp;delim));
    %let rc=%sysfunc(libname(out&amp;amp;i,%scan(&amp;amp;paths,&amp;amp;i,&amp;amp;delim)));
    %do; out&amp;amp;i..&amp;amp;dsname%end;
    %end;
%mend;

data %multiout(C:\Out1 C:\Out2),dsname=want);
  set have;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The good thing about this solution is that the input data is only read once.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I added a DELIM parameter in case you have blanks in you paths. In that case use another delimiter, e.g.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data %multiout(C:\Out1 data|C:\Out2 xxx),dsname=want,delim=|);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 07 Sep 2020 08:45:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Update-Multiple-Codes-at-the-Same-Time/m-p/681977#M206381</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2020-09-07T08:45:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to Update Multiple Codes at the Same Time?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Update-Multiple-Codes-at-the-Same-Time/m-p/682059#M206432</link>
      <description>&lt;P&gt;It might be a very good idea to describe exactly why you need 5 copies of a data set in 5 different libraries.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can see cases where "something happens" and the sets are not the same any more and you get undesirable results.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Sep 2020 19:01:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Update-Multiple-Codes-at-the-Same-Time/m-p/682059#M206432</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-09-07T19:01:29Z</dc:date>
    </item>
  </channel>
</rss>

