<?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 can I drop variables from Data Set A based on their membership of Data Set B in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-drop-variables-from-Data-Set-A-based-on-their/m-p/325437#M72377</link>
    <description>Thanks for your suggestion.&lt;BR /&gt;&lt;BR /&gt;I will explore this tomorrow and then get back to you.&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;&lt;BR /&gt;##- Please type your reply above this line. Simple formatting, no&lt;BR /&gt;attachments. -##</description>
    <pubDate>Tue, 17 Jan 2017 19:36:21 GMT</pubDate>
    <dc:creator>JonDickens1607</dc:creator>
    <dc:date>2017-01-17T19:36:21Z</dc:date>
    <item>
      <title>How can I drop variables from Data Set A based on their membership of Data Set B</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-drop-variables-from-Data-Set-A-based-on-their/m-p/325400#M72370</link>
      <description>&lt;P&gt;My SAS Code below is used to&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;a. Drop Variables from a Data Set&lt;/P&gt;&lt;P&gt;b. Construct Macro Variables containing Lists of Variable Names&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I drop variables from Data Set A based on their membership of Data Set B&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/* CONSTRUCT THE MACRO VARIABLE NUM_VARS_LIST TO CONTAIN THE LIST OF NUMERIC PREDICTOR VARIABLES FOR FUTURE ANALYSIS */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ODS OUTPUT NLEVELS = LIBXYZ.NUM_VAR_LEVELS;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC FREQ&lt;BR /&gt;DATA = LIBXYZ.DEVELOPMENT_SAMPLE_03N &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /* SOURCE INPUT DATA SET */&lt;BR /&gt;NLEVELS ;&lt;BR /&gt;TABLES _NUMERIC_ / NOPRINT ; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;/* ONLY NUMERIC VARIABLES */&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/* IDENTIFY THE NON-VARIABLES TO BE DELETED FROM THE INPUT DATA SETS : SELECT THE NUMERIC VARIABLES TO BE DROPPED: */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA&lt;BR /&gt;LIBXYZ.DROPNUMVARS (RENAME = (TABLEVAR = NUMVAR_NAME));&lt;BR /&gt;SET LIBXYZ.NUM_VAR_LEVELS (WHERE = (NLEVELS = 1 OR NNONMISSLEVELS IN (0 , 1) ));&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/* There were 2 observations read from the data set LIBXYZ.NUM_VAR_LEVELS WHERE (NLEVELS=1) or NNONMISSLEVELS in (0, 1) &amp;nbsp;The data set LIBXYZ.DROPNUMVARS has 2 observations and 5 variables. */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;TITLE ' NUMERIC VARIABLES WHERE [ NLEVELS = 1 OR NNONMISSLEVELS IN (0 , 1) ] TO BE DROPPED FROM THE DATA SET' ;&lt;/P&gt;&lt;P&gt;PROC PRINT&lt;BR /&gt;DATA = LIBXYZ.DROPNUMVARS;&lt;BR /&gt;RUN ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/* DROP THE SELECTED NUMERIC VARIABLES */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I drop variables from Data Set &lt;SPAN&gt;LIBXYZ.DEVELOPMENT_SAMPLE_03N&lt;/SPAN&gt; based on their membership of Data Set &lt;SPAN&gt;LIBXYZ.DROPNUMVARS&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After that I want to create the the macro variable list:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SQL&lt;BR /&gt;NOPRINT;&lt;BR /&gt;SELECT TABLEVAR&lt;BR /&gt;INTO :NUM_VARS_LIST SEPARATED BY ' '&lt;BR /&gt;FROM LIBXYZ.NUM_VAR_LEVELS &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /* ODS DATA SET NLEVELS = NUM_VAR_LEVELS */&lt;BR /&gt;;&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/********************************************************************************************************************************/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jan 2017 18:54:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-drop-variables-from-Data-Set-A-based-on-their/m-p/325400#M72370</guid>
      <dc:creator>JonDickens1607</dc:creator>
      <dc:date>2017-01-17T18:54:27Z</dc:date>
    </item>
    <item>
      <title>Re: How can I drop variables from Data Set A based on their membership of Data Set B</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-drop-variables-from-Data-Set-A-based-on-their/m-p/325430#M72373</link>
      <description>&lt;P&gt;Why don't you just change the proc sql code and add a final data step that uses the macro variable? e.g.,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC SQL&lt;BR /&gt;NOPRINT;&lt;BR /&gt;SELECT numvar_name&lt;BR /&gt;INTO :NUM_VARS_LIST SEPARATED BY ' '&lt;BR /&gt;FROM LIBXYZ.DROPNUMVARS /* ODS DATA SET NLEVELS = NUM_VAR_LEVELS */&lt;BR /&gt;;&lt;BR /&gt;QUIT;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data LIBXYZ.want;&lt;BR /&gt; set LIBXYZ.DEVELOPMENT_SAMPLE_03N (drop=&amp;amp;num_vars_list.);&lt;BR /&gt;run;&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jan 2017 19:23:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-drop-variables-from-Data-Set-A-based-on-their/m-p/325430#M72373</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-01-17T19:23:54Z</dc:date>
    </item>
    <item>
      <title>Re: How can I drop variables from Data Set A based on their membership of Data Set B</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-drop-variables-from-Data-Set-A-based-on-their/m-p/325437#M72377</link>
      <description>Thanks for your suggestion.&lt;BR /&gt;&lt;BR /&gt;I will explore this tomorrow and then get back to you.&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;&lt;BR /&gt;##- Please type your reply above this line. Simple formatting, no&lt;BR /&gt;attachments. -##</description>
      <pubDate>Tue, 17 Jan 2017 19:36:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-drop-variables-from-Data-Set-A-based-on-their/m-p/325437#M72377</guid>
      <dc:creator>JonDickens1607</dc:creator>
      <dc:date>2017-01-17T19:36:21Z</dc:date>
    </item>
    <item>
      <title>Re: How can I drop variables from Data Set A based on their membership of Data Set B</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-drop-variables-from-Data-Set-A-based-on-their/m-p/325519#M72398</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Not sure I understood your problem but this may help.

data a;
 set sashelp.class;
run;quit;

data b;
 set sashelp.class(keep=name age);
run;quit;

data keep_only_variables_in_b;
  set b(where=(1=2)) a open=defer;
run;quit;

Up to 40 obs from keep_only_variables_in_b total obs=19

Obs    NAME                 AGE

  1    Alfred                14
  2    Alice                 13
  3    Barbara               13
  4    Carol                 14
 ...
 15    Philip                16
 16    Robert                12
 17    Ronald                15
 18    Thomas                11
 19    William               15

NOTE: There were 0 observations read from the data set WORK.B.
      WHERE 0 /* an obviously FALSE WHERE clause */ ;
NOTE: For OPEN=DEFER processing, all variables processed should be
specified by the first data set listed in the SET statement.
NOTE: Variable SEX, found on WORK.A, is being ignored.
NOTE: Variable HEIGHT, found on WORK.A, is being ignored.
NOTE: Variable WEIGHT, found on WORK.A, is being ignored.
NOTE: There were 19 observations read from the data set WORK.A.
NOTE: The data set WORK.KEEP_ONLY_VARIABLES_IN_B has 19 observations and 2 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 Jan 2017 00:00:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-drop-variables-from-Data-Set-A-based-on-their/m-p/325519#M72398</guid>
      <dc:creator>rogerjdeangelis</dc:creator>
      <dc:date>2017-01-18T00:00:17Z</dc:date>
    </item>
  </channel>
</rss>

