<?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 make the same changes in many datasets in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/make-the-same-changes-in-many-datasets/m-p/330599#M74200</link>
    <description>&lt;P&gt;I have a bunch of raw datasets, but for one subject, it has two IDs.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to change the wrong ID to the correct one, and generate another set of raw data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there an efficient way to do this change without running it many times for each dataset?&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data newlib.right_ID;&lt;BR /&gt;set raw.wrong_ID;&lt;BR /&gt;if ID="A0001" then ID='B0001";&lt;BR /&gt;run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 07 Feb 2017 20:28:28 GMT</pubDate>
    <dc:creator>fengyuwuzu</dc:creator>
    <dc:date>2017-02-07T20:28:28Z</dc:date>
    <item>
      <title>make the same changes in many datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/make-the-same-changes-in-many-datasets/m-p/330599#M74200</link>
      <description>&lt;P&gt;I have a bunch of raw datasets, but for one subject, it has two IDs.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to change the wrong ID to the correct one, and generate another set of raw data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there an efficient way to do this change without running it many times for each dataset?&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data newlib.right_ID;&lt;BR /&gt;set raw.wrong_ID;&lt;BR /&gt;if ID="A0001" then ID='B0001";&lt;BR /&gt;run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Feb 2017 20:28:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/make-the-same-changes-in-many-datasets/m-p/330599#M74200</guid>
      <dc:creator>fengyuwuzu</dc:creator>
      <dc:date>2017-02-07T20:28:28Z</dc:date>
    </item>
    <item>
      <title>Re: make the same changes in many datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/make-the-same-changes-in-many-datasets/m-p/330601#M74201</link>
      <description>Did you think of Macro's to achieve the outcome ?</description>
      <pubDate>Tue, 07 Feb 2017 20:33:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/make-the-same-changes-in-many-datasets/m-p/330601#M74201</guid>
      <dc:creator>anoopmohandas7</dc:creator>
      <dc:date>2017-02-07T20:33:36Z</dc:date>
    </item>
    <item>
      <title>Re: make the same changes in many datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/make-the-same-changes-in-many-datasets/m-p/330603#M74203</link>
      <description>&lt;P&gt;yes, a macro and loop through list&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2017 20:35:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/make-the-same-changes-in-many-datasets/m-p/330603#M74203</guid>
      <dc:creator>fengyuwuzu</dc:creator>
      <dc:date>2017-02-07T20:35:13Z</dc:date>
    </item>
    <item>
      <title>Re: make the same changes in many datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/make-the-same-changes-in-many-datasets/m-p/330605#M74204</link>
      <description>&lt;P&gt;Do you need to do that for all of the datasets in the RAW library?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2017 20:39:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/make-the-same-changes-in-many-datasets/m-p/330605#M74204</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-02-07T20:39:11Z</dc:date>
    </item>
    <item>
      <title>Re: make the same changes in many datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/make-the-same-changes-in-many-datasets/m-p/330607#M74206</link>
      <description>not all, only those with wrong ID</description>
      <pubDate>Tue, 07 Feb 2017 20:46:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/make-the-same-changes-in-many-datasets/m-p/330607#M74206</guid>
      <dc:creator>fengyuwuzu</dc:creator>
      <dc:date>2017-02-07T20:46:23Z</dc:date>
    </item>
    <item>
      <title>Re: make the same changes in many datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/make-the-same-changes-in-many-datasets/m-p/330612#M74208</link>
      <description>&lt;P&gt;Do you have a dataset with the wrong ID's?&lt;/P&gt;
&lt;P&gt;How many datasets and do they have a naming convention?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/56807"&gt;@fengyuwuzu&lt;/a&gt;&amp;nbsp;You've posted enough to know to post sample data, so can I assume you're only asking for methodological help here?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can create a format and apply it to all your datasets so that it 'shows' as correct or manually loop through and reassign. You can't reassign using a proc datasets so that means recreating your data. If you use a format, you can apply it using proc datasets and not recreate all your datasets. Depending on the size of datasets this may be a factor in the solution you choose.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It seems easier to create a format and use as you go as well, especially if changes occur over time.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2017 21:09:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/make-the-same-changes-in-many-datasets/m-p/330612#M74208</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-02-07T21:09:52Z</dc:date>
    </item>
    <item>
      <title>Re: make the same changes in many datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/make-the-same-changes-in-many-datasets/m-p/330613#M74209</link>
      <description>&lt;P&gt;Do you have a file that contains a list of those file names?&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2017 21:11:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/make-the-same-changes-in-many-datasets/m-p/330613#M74209</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-02-07T21:11:00Z</dc:date>
    </item>
    <item>
      <title>Re: make the same changes in many datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/make-the-same-changes-in-many-datasets/m-p/330614#M74210</link>
      <description>&lt;P&gt;Assuming you have a file that contains a list of those files, here is one way to do it:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;libname raw 'c:\art\test';
libname newlib 'c:\art\out';

/*proc sql noprint;*/
/*  select file  into: files separated by '*'*/
/*    from dictionary.tables*/
/*      where libname='RAW'*/
/*  ;*/
/*quit;*/

data filelist;
  informat file $32.;
  input file;
  cards;
test1
test2
test3
;

proc sql noprint;
  select file  into: files separated by '*'
    from work.filelist
  ;
quit;

%macro doit;
  %let i=1;
  %do %while (%scan(&amp;amp;files.,&amp;amp;i.,*) ne );
    data newlib.%scan(&amp;amp;files.,&amp;amp;i.,*);
      set raw.%scan(&amp;amp;files.,&amp;amp;i.);
      if ID="A0001" then ID="B0001";
    run;
    %let i=%eval(&amp;amp;i.+1);
  %end;
%mend doit;
%doit
&lt;/PRE&gt;
&lt;P&gt;Note that I commented out the section that would have accomplished the task for all of the files in the raw directory.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HTH,&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2017 21:19:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/make-the-same-changes-in-many-datasets/m-p/330614#M74210</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-02-07T21:19:33Z</dc:date>
    </item>
    <item>
      <title>Re: make the same changes in many datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/make-the-same-changes-in-many-datasets/m-p/330651#M74221</link>
      <description>Can you explain 'ne' in the while loop.&lt;BR /&gt;%while (%scan(&amp;amp;files.,&amp;amp;i.,*) ne );&lt;BR /&gt;&lt;BR /&gt;Thanks.</description>
      <pubDate>Tue, 07 Feb 2017 22:58:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/make-the-same-changes-in-many-datasets/m-p/330651#M74221</guid>
      <dc:creator>anoopmohandas7</dc:creator>
      <dc:date>2017-02-07T22:58:26Z</dc:date>
    </item>
    <item>
      <title>Re: make the same changes in many datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/make-the-same-changes-in-many-datasets/m-p/330653#M74223</link>
      <description>&lt;P&gt;Simply a way of defining a where condition to keep going until nothing is found&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2017 23:04:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/make-the-same-changes-in-many-datasets/m-p/330653#M74223</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-02-07T23:04:22Z</dc:date>
    </item>
  </channel>
</rss>

