<?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 - DROP statement in a join - Discrimination between t1 and t2 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-DROP-statement-in-a-join-Discrimination-between-t1-and/m-p/276869#M55516</link>
    <description>&lt;P&gt;&lt;SPAN&gt;Use drop= table option in &lt;STRONG&gt;From&lt;/STRONG&gt; clause as shown below. &amp;nbsp;It would drop MEASURE column from TABLE1 and not from TABLE2.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;PROC SQL;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;CREATE TABLE RESULT &amp;nbsp; AS&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SELECT t1.*,t2.*&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;FROM TABLE1&lt;STRONG&gt;(DROP=MEASURE)&lt;/STRONG&gt; &amp;nbsp;t1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;LEFT JOIN TABLE2 t2 ON(t1.Entity_ID = t2.ENTITY_ID) AND (t1.Reported_Period = t2.REPORTED_PERIOD)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;WHERE t1.Reported_Period &amp;gt;= '31Dec2014'd;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;QUIT;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 13 Jun 2016 08:35:00 GMT</pubDate>
    <dc:creator>RahulG</dc:creator>
    <dc:date>2016-06-13T08:35:00Z</dc:date>
    <item>
      <title>PROC SQL - DROP statement in a join - Discrimination between t1 and t2</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-DROP-statement-in-a-join-Discrimination-between-t1-and/m-p/276867#M55514</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am strugling a bit dropping variables in a join statement: I need to drop some variables from t1 and other variables from t2 (the variables I need to drop are not keys).&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the code below some variables are the same in both tables (because of the *) I cannot name manually each variable because there are hundreds of them and they can change.&lt;/P&gt;&lt;P&gt;Looking at the documentation it seems that the drop statement can be applied only in the result table (see drop statement after the CREATE).&lt;/P&gt;&lt;P&gt;Does anyone know how to differentiate variables from t1 and t2 in the DROP statement? (Maybe there is another solution?)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;BR /&gt;CREATE TABLE RESULT (DROP=MEASURE) &amp;nbsp;AS&lt;BR /&gt;SELECT t1.*,t2.*&lt;BR /&gt;FROM TABLE1 t1&lt;BR /&gt;LEFT JOIN TABLE2 t2 ON(t1.Entity_ID = t2.ENTITY_ID) AND (t1.Reported_Period = t2.REPORTED_PERIOD)&lt;BR /&gt;WHERE t1.Reported_Period &amp;gt;= '31Dec2014'd;&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In advance, thank you very much,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jun 2016 08:10:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-DROP-statement-in-a-join-Discrimination-between-t1-and/m-p/276867#M55514</guid>
      <dc:creator>Escada</dc:creator>
      <dc:date>2016-06-13T08:10:54Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL - DROP statement in a join - Discrimination between t1 and t2</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-DROP-statement-in-a-join-Discrimination-between-t1-and/m-p/276869#M55516</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Use drop= table option in &lt;STRONG&gt;From&lt;/STRONG&gt; clause as shown below. &amp;nbsp;It would drop MEASURE column from TABLE1 and not from TABLE2.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;PROC SQL;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;CREATE TABLE RESULT &amp;nbsp; AS&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SELECT t1.*,t2.*&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;FROM TABLE1&lt;STRONG&gt;(DROP=MEASURE)&lt;/STRONG&gt; &amp;nbsp;t1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;LEFT JOIN TABLE2 t2 ON(t1.Entity_ID = t2.ENTITY_ID) AND (t1.Reported_Period = t2.REPORTED_PERIOD)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;WHERE t1.Reported_Period &amp;gt;= '31Dec2014'd;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;QUIT;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jun 2016 08:35:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-DROP-statement-in-a-join-Discrimination-between-t1-and/m-p/276869#M55516</guid>
      <dc:creator>RahulG</dc:creator>
      <dc:date>2016-06-13T08:35:00Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL - DROP statement in a join - Discrimination between t1 and t2</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-DROP-statement-in-a-join-Discrimination-between-t1-and/m-p/276872#M55518</link>
      <description>&lt;P&gt;Well, if your datasets have hundreds of variables - I would fits ask why, as that is never a good idea to have so many varibles - secondly I would consider using datastep rather than SQL. &amp;nbsp;SQL is built to handle relational database models, i.e. tables with few variables and many observations with links between tables. &amp;nbsp;SAS is more flexible than that allowing a more tabular form. &amp;nbsp;However for any kind of processing its really not a good idea to have hundreds of variables - at some point you will need to know what they are, either in this sql or later on - so that is the real underlying problem. &amp;nbsp;Now you could still do this with datastep as (not tested obviously):&lt;/P&gt;
&lt;PRE&gt;/* Note assumes data is sorted*/
data want;
  merge table1 (in=a drop=somevariable where=(reported_period &amp;gt;= '31Dec2014'd) 
        table2 (in=b drop=measure);
  by entityid;
  if a;
run;
 &lt;/PRE&gt;
&lt;P&gt;However I still strongly advise you to look at your data and strucutre it in a way that is useful for your programming to save further problems.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jun 2016 08:43:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-DROP-statement-in-a-join-Discrimination-between-t1-and/m-p/276872#M55518</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-06-13T08:43:15Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL - DROP statement in a join - Discrimination between t1 and t2</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-DROP-statement-in-a-join-Discrimination-between-t1-and/m-p/277021#M55573</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/76510"&gt;@Escada&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I cannot name manually each variable because there are hundreds of them and they can change.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Given that same-name variables will create problems, how can you build a robust query with &lt;SPAN&gt;t1.*,t2.*&lt;/SPAN&gt;? You must enumerate the set of variables that you need. Build the list in Excel or some text processor.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jun 2016 18:28:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-DROP-statement-in-a-join-Discrimination-between-t1-and/m-p/277021#M55573</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-06-13T18:28:40Z</dc:date>
    </item>
  </channel>
</rss>

