<?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: proc sql how to exclude variables from being selected in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-how-to-exclude-variables-from-being-selected/m-p/676248#M203891</link>
    <description>&lt;P&gt;No need to drop&amp;nbsp;b.RECORD_NUMBER because you already have a.RECORD_NUMBER and you cannot have two variables with the same name.&amp;nbsp; To drop MONTH use DROP= dataset option.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;INITIAL_DATA(drop=month) as b&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want to eliminate messages about duplicate variable names then rename RECORD_NUMBER and then add DROP= dataset option to the output dataset.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;create table Final_Information(drop=b_record_number) as
   select A.*
         ,B.*    
   from AC.TEST as a
   left join INITIAL_DATA (drop=month rename=(record_number=b_record_number)) as b
         on a.RECORD_NUMBER=b.b_RECORD_NUMBER
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 12 Aug 2020 17:22:40 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2020-08-12T17:22:40Z</dc:date>
    <item>
      <title>proc sql how to exclude variables from being selected</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-how-to-exclude-variables-from-being-selected/m-p/676239#M203885</link>
      <description>&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am creating a table using proc sql and was wondering if someone could help me to select all of the variables from dataset B in a left join, except for two variables: "RECORD_NUMBER" (I would need to keep RECORD_NUMBER as I will left join on a.RECORD_NUMBER=b.RECORD_NUMBER, but only dataset A's&amp;nbsp;RECORD_NUMBER would be selected to be shown in the table) and "MONTH". The preferred option would be to just exclude these two variables from dataset B, as there are a fair amount of variables that would need to be listed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
   create table Final_Information as
   select A.*
         ,B.* /*How to keep all of B's variables, except "B.RECORD_NUMBER" and "B.MONTH"?*/
   from AC.TEST as a
   left join INITIAL_DATA as b
         on a.RECORD_NUMBER=b.RECORD_NUMBER
   ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Aug 2020 17:02:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-how-to-exclude-variables-from-being-selected/m-p/676239#M203885</guid>
      <dc:creator>Justin9</dc:creator>
      <dc:date>2020-08-12T17:02:50Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql how to exclude variables from being selected</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-how-to-exclude-variables-from-being-selected/m-p/676244#M203889</link>
      <description>&lt;P&gt;Formal syntax would be instead of ,b.* to list the variables&lt;/P&gt;
&lt;P&gt;,b.variable1, b.variable2, b.variable3 &amp;lt;etc&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The quick and dirty easy data set option Drop on B won't work because one of the variables you want to drop is used in an expression. Do you also have a MONTH variable in the A data set?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Aug 2020 17:16:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-how-to-exclude-variables-from-being-selected/m-p/676244#M203889</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-08-12T17:16:45Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql how to exclude variables from being selected</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-how-to-exclude-variables-from-being-selected/m-p/676245#M203890</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
   create table Final_Information as
   select A.*
         ,B.* /*How to keep all of B's variables, except "B.RECORD_NUMBER" and "B.MONTH"?*/
   from AC.TEST as a
   left join INITIAL_DATA (drop=month) as b
         on a.RECORD_NUMBER=b.RECORD_NUMBER
   ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I think this would work but may still give you a note in the log.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Aug 2020 17:18:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-how-to-exclude-variables-from-being-selected/m-p/676245#M203890</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-08-12T17:18:54Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql how to exclude variables from being selected</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-how-to-exclude-variables-from-being-selected/m-p/676248#M203891</link>
      <description>&lt;P&gt;No need to drop&amp;nbsp;b.RECORD_NUMBER because you already have a.RECORD_NUMBER and you cannot have two variables with the same name.&amp;nbsp; To drop MONTH use DROP= dataset option.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;INITIAL_DATA(drop=month) as b&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want to eliminate messages about duplicate variable names then rename RECORD_NUMBER and then add DROP= dataset option to the output dataset.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;create table Final_Information(drop=b_record_number) as
   select A.*
         ,B.*    
   from AC.TEST as a
   left join INITIAL_DATA (drop=month rename=(record_number=b_record_number)) as b
         on a.RECORD_NUMBER=b.b_RECORD_NUMBER
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Aug 2020 17:22:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-how-to-exclude-variables-from-being-selected/m-p/676248#M203891</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-08-12T17:22:40Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql how to exclude variables from being selected</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-how-to-exclude-variables-from-being-selected/m-p/676250#M203893</link>
      <description>&lt;P&gt;Thanks for your reply! I would have typed out the usual b.[variable], b.[variable] etc. but there are a lot of variables in dataset B that I want to join on, so was wondering if there was any code to not select only the "RECORD_NUMBER" and "MONTH" (without dropping it from the INITIAL_DATA dataset). When I write A.*, there is the "MONTH" variable in dataset A already (which is the only one I want to show in the final table) and a warning appears on my log saying that it's already in the table, so that's why the preference would be to simply not select the two variables ("RECORD_NUMBER" and "MONTH"), but not have to list out every variable I want in dataset B (as there are quite a lot).&lt;/P&gt;</description>
      <pubDate>Wed, 12 Aug 2020 17:23:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-how-to-exclude-variables-from-being-selected/m-p/676250#M203893</guid>
      <dc:creator>Justin9</dc:creator>
      <dc:date>2020-08-12T17:23:40Z</dc:date>
    </item>
  </channel>
</rss>

