<?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: Dropping of common variables from multiple datasets in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Dropping-of-common-variables-from-multiple-datasets/m-p/388003#M11705</link>
    <description>&lt;P&gt;Do you know the list ahead of time or need to determine it first?&lt;/P&gt;</description>
    <pubDate>Mon, 14 Aug 2017 22:18:07 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-08-14T22:18:07Z</dc:date>
    <item>
      <title>Dropping of common variables from multiple datasets</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Dropping-of-common-variables-from-multiple-datasets/m-p/388002#M11704</link>
      <description>&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have multiple datasets in SAS which have 10 common system variables which I would like to drop in one go.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any&amp;nbsp;easy way to do it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;Dataset 1 with common system variable A, B, C, D, E, F, G, H, I, J&lt;/P&gt;&lt;P&gt;Dataset 2&amp;nbsp;with common system variable A, B, C, D, E, F, G, H, I, J&lt;/P&gt;&lt;P&gt;and so on...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks, N&lt;/P&gt;</description>
      <pubDate>Mon, 14 Aug 2017 22:12:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Dropping-of-common-variables-from-multiple-datasets/m-p/388002#M11704</guid>
      <dc:creator>nayakn</dc:creator>
      <dc:date>2017-08-14T22:12:06Z</dc:date>
    </item>
    <item>
      <title>Re: Dropping of common variables from multiple datasets</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Dropping-of-common-variables-from-multiple-datasets/m-p/388003#M11705</link>
      <description>&lt;P&gt;Do you know the list ahead of time or need to determine it first?&lt;/P&gt;</description>
      <pubDate>Mon, 14 Aug 2017 22:18:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Dropping-of-common-variables-from-multiple-datasets/m-p/388003#M11705</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-08-14T22:18:07Z</dc:date>
    </item>
    <item>
      <title>Re: Dropping of common variables from multiple datasets</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Dropping-of-common-variables-from-multiple-datasets/m-p/388005#M11706</link>
      <description>&lt;P&gt;I know the list of varibles which needs to be dropped.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Aug 2017 22:26:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Dropping-of-common-variables-from-multiple-datasets/m-p/388005#M11706</guid>
      <dc:creator>nayakn</dc:creator>
      <dc:date>2017-08-14T22:26:10Z</dc:date>
    </item>
    <item>
      <title>Re: Dropping of common variables from multiple datasets</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Dropping-of-common-variables-from-multiple-datasets/m-p/388011#M11707</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/158926"&gt;@nayakn&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Something like below should work.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  alter table dataset_1
    drop A, B, C, D, E, F, G, H, I, J
  ;
  alter table dataset_2
    drop A, B, C, D, E, F, G, H, I, J
  ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 14 Aug 2017 22:42:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Dropping-of-common-variables-from-multiple-datasets/m-p/388011#M11707</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-08-14T22:42:06Z</dc:date>
    </item>
    <item>
      <title>Re: Dropping of common variables from multiple datasets</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Dropping-of-common-variables-from-multiple-datasets/m-p/388016#M11708</link>
      <description>&lt;P&gt;Thanks for the quick reponse.&lt;/P&gt;&lt;P&gt;I can do it using below method but I have to specify this for each dataset.&lt;/P&gt;&lt;P&gt;Is there a easy and efficient way so that I can read all the datasets in one go and drop the common variables?&amp;nbsp;Can we do it using Macro?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Aug 2017 22:51:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Dropping-of-common-variables-from-multiple-datasets/m-p/388016#M11708</guid>
      <dc:creator>nayakn</dc:creator>
      <dc:date>2017-08-14T22:51:06Z</dc:date>
    </item>
    <item>
      <title>Re: Dropping of common variables from multiple datasets</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Dropping-of-common-variables-from-multiple-datasets/m-p/388023#M11709</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/158926"&gt;@nayakn&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a easy and efficient way so that I can read all the datasets in one go and drop the common variables?&amp;nbsp;Can we do it using Macro?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes and Yes, but you haven't provided enough information.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The working code is above but how do you identify which datasets need to have the variables dropped?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Whatever the rules are you can select the table names from sashelp.vtable and then use a loop to create the necessary&amp;nbsp;statements. The log has an example of how to loop over a list of variables.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Aug 2017 23:40:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Dropping-of-common-variables-from-multiple-datasets/m-p/388023#M11709</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-08-14T23:40:11Z</dc:date>
    </item>
    <item>
      <title>Re: Dropping of common variables from multiple datasets</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Dropping-of-common-variables-from-multiple-datasets/m-p/388075#M11714</link>
      <description>&lt;P&gt;Are all the datasets the same structure, i.e. do they all contain the same set of variables/types? &amp;nbsp;If so, the question would be why are they separate (keep same data together to avoid these kinds of excessive coding), e.g.:&lt;/P&gt;
&lt;PRE&gt;data mydata;
  set dataset: (drop=a b c d e f g h);
run;&lt;/PRE&gt;
&lt;P&gt;The above sets all dataset prefixed datasets into one dataset and drops the given variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If they are all different datasets, i.e no structural similarities then:&lt;/P&gt;
&lt;PRE&gt;data _null_;
  set sashelp.vtable (where=(libname="MYLIB"));
  call execute(cats('proc sql; alter table mylib.',memname,' drop a,b,c,d,e,f,g,h; quit;'));
run;&lt;/PRE&gt;
&lt;P&gt;This generates one&amp;nbsp;line of code per dataset in mylib libary and removes the given variables.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Aug 2017 08:10:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Dropping-of-common-variables-from-multiple-datasets/m-p/388075#M11714</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-08-15T08:10:35Z</dc:date>
    </item>
    <item>
      <title>Re: Dropping of common variables from multiple datasets</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Dropping-of-common-variables-from-multiple-datasets/m-p/388331#M11736</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/158926"&gt;@nayakn&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;I feel code and log remains easier to understand and maintain if you only use SAS macro code where you must.&lt;/P&gt;
&lt;P&gt;If this is just about repeating statements a few times then I'd go with such an approach.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you need something dynamic, i.e. for a varying number of SAS files in a library which follow some naming pattern then you could use macro code or may be even better the code&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9&lt;/a&gt;&amp;nbsp;posted already.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Aug 2017 22:03:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Dropping-of-common-variables-from-multiple-datasets/m-p/388331#M11736</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-08-15T22:03:30Z</dc:date>
    </item>
    <item>
      <title>Re: Dropping of common variables from multiple datasets</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Dropping-of-common-variables-from-multiple-datasets/m-p/388397#M11739</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9&lt;/a&gt; Thanks for the response. Strucutre of all datasets are different but all these datasets do have common system generated variables which I have to remove.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I used the below code in my program but it gives an error message, refer to appended sceenshot.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;!--   Google Tag Manager   --&gt;&lt;!--   End Google Tag Manager   --&gt;&lt;/P&gt;&lt;DIV class="lia-page"&gt;&lt;CENTER&gt;&lt;DIV class="MinimumWidthContainer"&gt;&lt;DIV class="min-width-wrapper"&gt;&lt;DIV class="min-width"&gt;&lt;DIV class="lia-content"&gt;&lt;DIV class="lia-quilt lia-quilt-reply-page lia-quilt-layout-one-column lia-top-quilt"&gt;&lt;DIV class="lia-quilt-row lia-quilt-row-header"&gt;&lt;DIV class="lia-quilt-row lia-quilt-row-main"&gt;&lt;DIV class="lia-quilt-column lia-quilt-column-24 lia-quilt-column-single lia-quilt-column-main-content"&gt;&lt;DIV class="lia-quilt-column-alley lia-quilt-column-alley-single"&gt;&lt;DIV class="lia-panel lia-panel-section lia-component-editor"&gt;&lt;DIV class="lia-decoration-border"&gt;&lt;DIV class="lia-decoration-border-content"&gt;&lt;DIV&gt;&lt;DIV class="lia-panel-content-wrapper"&gt;&lt;DIV class="lia-panel-content"&gt;&lt;DIV class="lia-message-view message-uid-388075"&gt;&lt;DIV&gt;&lt;DIV class="lia-js-resize-images lia-component-forums-widget-board-message-view"&gt;&lt;DIV&gt;&lt;DIV class="lia-message-board lia-panel-message lia-js-data-messageUid-388075"&gt;&lt;DIV class="lia-panel-message-content"&gt;&lt;DIV class="lia-decoration-border"&gt;&lt;DIV class="lia-decoration-border-content"&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV class="lia-quilt lia-quilt-forum-message lia-quilt-layout-forum-message"&gt;&lt;DIV class="lia-quilt-row lia-quilt-row-forum-message-main"&gt;&lt;DIV class="lia-quilt-column lia-quilt-column-20 lia-quilt-column-right lia-quilt-column-main-right"&gt;&lt;DIV class="lia-quilt-column-alley lia-quilt-column-alley-right"&gt;&lt;DIV class="lia-message-body lia-component-body"&gt;&lt;DIV class="lia-message-body-content"&gt;&lt;PRE&gt;data _null_;
  set sashelp.vtable (where=(libname="SDTM_MAN"));
  call execute(cats('proc sql; alter table SDTM_MAN.',memname,' drop projectid; quit;'));
run;&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/CENTER&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 16 Aug 2017 10:26:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Dropping-of-common-variables-from-multiple-datasets/m-p/388397#M11739</guid>
      <dc:creator>nayakn</dc:creator>
      <dc:date>2017-08-16T10:26:38Z</dc:date>
    </item>
    <item>
      <title>Re: Dropping of common variables from multiple datasets</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Dropping-of-common-variables-from-multiple-datasets/m-p/388663#M11742</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/158926"&gt;@nayakn&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;The log shows you that there is a blank required before the DROP keyword. Use CATX() with a blank as delimiter instead of CATS() and things should work.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2017 00:04:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Dropping-of-common-variables-from-multiple-datasets/m-p/388663#M11742</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-08-17T00:04:17Z</dc:date>
    </item>
    <item>
      <title>Re: Dropping of common variables from multiple datasets</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Dropping-of-common-variables-from-multiple-datasets/m-p/388737#M11744</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;Thanks for response. I was able to get rid of error message.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2017 10:43:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Dropping-of-common-variables-from-multiple-datasets/m-p/388737#M11744</guid>
      <dc:creator>nayakn</dc:creator>
      <dc:date>2017-08-17T10:43:52Z</dc:date>
    </item>
    <item>
      <title>Re: Dropping of common variables from multiple datasets</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Dropping-of-common-variables-from-multiple-datasets/m-p/389065#M11758</link>
      <description>&lt;P&gt;Was out of office for a couple of days. &amp;nbsp;For future reference, please mark the answer as the correct answer, not your response to it. &amp;nbsp;This both rewards the person who put the effort in to give you the answer and puts that correct answer up underneath the question so it is easy to pair the two.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Aug 2017 08:42:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Dropping-of-common-variables-from-multiple-datasets/m-p/389065#M11758</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-08-18T08:42:00Z</dc:date>
    </item>
  </channel>
</rss>

