<?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 do I create a SAS macro to read and copy tables based from anoter table vales in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-do-I-create-a-SAS-macro-to-read-and-copy-tables-based-from/m-p/794787#M254860</link>
    <description>&lt;P&gt;Can you help me with one more thing?&lt;/P&gt;&lt;P&gt;There are two tables. One of them is what board to copy and where you helped. The other step would be to overwrite or clear certain fields with a default value based on another table.&lt;/P&gt;&lt;P&gt;So if the value of to_archive is Y and the value of the procedure field is default_value then it should be overwritten with the value written there and if the value of to_empty is then emptied that field.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data work.to_archive_and_deperson;
input libname:$32.  tablename:$32. to_libname:$32. to_tablename:$32.;
datalines;
sashelp class work copied_class
sashelp cars work copied_cars
;
run;

data work.columns_to_deperson;
infile datalines delimiter=',';
input sas_libname:$32. sas_table_name:$32. column_name:$32.  to_archeve:$1. procedure:$32. default_value:$32.;
datalines;
sashelp,class,name,Y,default_value,XXXX
sashelp,cars,modell,N, ,  
sashelp,cars,make,Y,to_empty,,
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks a lot!&lt;/P&gt;</description>
    <pubDate>Mon, 07 Feb 2022 13:40:50 GMT</pubDate>
    <dc:creator>ger15xxhcker</dc:creator>
    <dc:date>2022-02-07T13:40:50Z</dc:date>
    <item>
      <title>how do I create a SAS macro to read and copy tables based from anoter table vales</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-do-I-create-a-SAS-macro-to-read-and-copy-tables-based-from/m-p/794752#M254838</link>
      <description>&lt;P&gt;data work.TEST_TABLE;&lt;BR /&gt;input libname:$32. tablename:$32. to_libname:$32. to_tablename:$32.;&lt;BR /&gt;datalines;&lt;BR /&gt;sashelp class work copied_class&lt;BR /&gt;sashelp cars work copied_cars&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to create a macro that reads from a table and copies it according to the specified conditions. So it reads from which lib to which lib and which table to copy. Could you help put this into practice? Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 07 Feb 2022 09:31:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-do-I-create-a-SAS-macro-to-read-and-copy-tables-based-from/m-p/794752#M254838</guid>
      <dc:creator>ger15xxhcker</dc:creator>
      <dc:date>2022-02-07T09:31:53Z</dc:date>
    </item>
    <item>
      <title>Re: how do I create a SAS macro to read and copy tables based from anoter table vales</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-do-I-create-a-SAS-macro-to-read-and-copy-tables-based-from/m-p/794754#M254840</link>
      <description>&lt;P&gt;Unless you have a good reason why you want a macro to do this, Call Execute is a nice tool to create data driven code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.TEST_TABLE;
input libname:$32. tablename:$32. to_libname:$32. to_tablename:$32.;
datalines;
sashelp class work copied_class
sashelp cars work copied_cars
;
run;

data _null_;
   set test_table;
   call execute
   (compbl(cat(
   "data ", catx('.', to_libname, to_tablename), ";
       set ", catx('.', libname, tablename),";
   run;"
    )));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 07 Feb 2022 09:50:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-do-I-create-a-SAS-macro-to-read-and-copy-tables-based-from/m-p/794754#M254840</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-02-07T09:50:08Z</dc:date>
    </item>
    <item>
      <title>Re: how do I create a SAS macro to read and copy tables based from anoter table vales</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-do-I-create-a-SAS-macro-to-read-and-copy-tables-based-from/m-p/794758#M254844</link>
      <description>&lt;P&gt;Thanks. It's works!&lt;/P&gt;</description>
      <pubDate>Mon, 07 Feb 2022 10:39:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-do-I-create-a-SAS-macro-to-read-and-copy-tables-based-from/m-p/794758#M254844</guid>
      <dc:creator>ger15xxhcker</dc:creator>
      <dc:date>2022-02-07T10:39:01Z</dc:date>
    </item>
    <item>
      <title>Re: how do I create a SAS macro to read and copy tables based from anoter table vales</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-do-I-create-a-SAS-macro-to-read-and-copy-tables-based-from/m-p/794771#M254852</link>
      <description>&lt;P&gt;Anytime&lt;/P&gt;</description>
      <pubDate>Mon, 07 Feb 2022 12:01:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-do-I-create-a-SAS-macro-to-read-and-copy-tables-based-from/m-p/794771#M254852</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-02-07T12:01:17Z</dc:date>
    </item>
    <item>
      <title>Re: how do I create a SAS macro to read and copy tables based from anoter table vales</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-do-I-create-a-SAS-macro-to-read-and-copy-tables-based-from/m-p/794787#M254860</link>
      <description>&lt;P&gt;Can you help me with one more thing?&lt;/P&gt;&lt;P&gt;There are two tables. One of them is what board to copy and where you helped. The other step would be to overwrite or clear certain fields with a default value based on another table.&lt;/P&gt;&lt;P&gt;So if the value of to_archive is Y and the value of the procedure field is default_value then it should be overwritten with the value written there and if the value of to_empty is then emptied that field.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data work.to_archive_and_deperson;
input libname:$32.  tablename:$32. to_libname:$32. to_tablename:$32.;
datalines;
sashelp class work copied_class
sashelp cars work copied_cars
;
run;

data work.columns_to_deperson;
infile datalines delimiter=',';
input sas_libname:$32. sas_table_name:$32. column_name:$32.  to_archeve:$1. procedure:$32. default_value:$32.;
datalines;
sashelp,class,name,Y,default_value,XXXX
sashelp,cars,modell,N, ,  
sashelp,cars,make,Y,to_empty,,
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks a lot!&lt;/P&gt;</description>
      <pubDate>Mon, 07 Feb 2022 13:40:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-do-I-create-a-SAS-macro-to-read-and-copy-tables-based-from/m-p/794787#M254860</guid>
      <dc:creator>ger15xxhcker</dc:creator>
      <dc:date>2022-02-07T13:40:50Z</dc:date>
    </item>
  </channel>
</rss>

