<?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: Drop and Keep Question in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Drop-and-Keep-Question/m-p/241863#M44846</link>
    <description>&lt;P&gt;So the following question led to my confusion:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Given what you know about how SAS processes the DROP and KEEP statements, would these two DATA steps create the same data set?&lt;/P&gt;&lt;P&gt;data work.subset1;&lt;BR /&gt;set orion.sales;&lt;BR /&gt;drop Salary;&lt;BR /&gt;Bonus=500;&lt;BR /&gt;Compensation=sum(Salary,Bonus);&lt;BR /&gt;BonusMonth=month(Hire_Date);&lt;BR /&gt;run;&lt;BR /&gt;data work.subset1;&lt;BR /&gt;set orion.sales;&lt;BR /&gt;Bonus=500;&lt;BR /&gt;Compensation=sum(Salary,Bonus);&lt;BR /&gt;BonusMonth=month(Hire_Date);&lt;BR /&gt;drop Salary;&lt;BR /&gt;run;&lt;BR /&gt;a. Yes&lt;BR /&gt;b. No&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Correct answer: a&lt;/P&gt;&lt;P&gt;Variables in the DROP statement are dropped during output, so they're available for calculations in the DATA step, even if they follow the statements that reference them.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If variables can still be used in the calculations, wouldn't that mean they still exist in the data set? Thanks much!&lt;/P&gt;</description>
    <pubDate>Tue, 05 Jan 2016 17:16:22 GMT</pubDate>
    <dc:creator>Durlov</dc:creator>
    <dc:date>2016-01-05T17:16:22Z</dc:date>
    <item>
      <title>Drop and Keep Question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Drop-and-Keep-Question/m-p/241852#M44842</link>
      <description>&lt;P&gt;Hello, can someone help me understand the reasons the Answer is 2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Given the SAS data set WORK.PRODUCT&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(See attached image).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I thought the answer would be 6 because as far as I understand it, dropping the variable only removes the variable from the output and not from the actual data set. So previously Work.Products had 5 variable. Work.Revenue inherited these 5 variable and added one more (Revenue). So that makes 6. Why am I wrong?&lt;/P&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/12168iE7FF9A82C440814E/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="SAS Question.PNG" title="SAS Question.PNG" /&gt;</description>
      <pubDate>Tue, 05 Jan 2016 16:12:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Drop-and-Keep-Question/m-p/241852#M44842</guid>
      <dc:creator>Durlov</dc:creator>
      <dc:date>2016-01-05T16:12:38Z</dc:date>
    </item>
    <item>
      <title>Re: Drop and Keep Question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Drop-and-Keep-Question/m-p/241856#M44844</link>
      <description>Dropping a variable removes it from the data set. &lt;BR /&gt;&lt;BR /&gt;I'm not sure how you're differentiating the output from the final dataset, but in this case they're the same thing. &lt;BR /&gt;&lt;BR /&gt;The correct answer is 2 -&lt;BR /&gt;-&amp;gt;Source Data = 4 variables&lt;BR /&gt;+-&amp;gt;calculate a new variable  = 5 variables&lt;BR /&gt;-&amp;gt;Drop 3 variables = 2 variables</description>
      <pubDate>Tue, 05 Jan 2016 16:25:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Drop-and-Keep-Question/m-p/241856#M44844</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-01-05T16:25:04Z</dc:date>
    </item>
    <item>
      <title>Re: Drop and Keep Question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Drop-and-Keep-Question/m-p/241863#M44846</link>
      <description>&lt;P&gt;So the following question led to my confusion:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Given what you know about how SAS processes the DROP and KEEP statements, would these two DATA steps create the same data set?&lt;/P&gt;&lt;P&gt;data work.subset1;&lt;BR /&gt;set orion.sales;&lt;BR /&gt;drop Salary;&lt;BR /&gt;Bonus=500;&lt;BR /&gt;Compensation=sum(Salary,Bonus);&lt;BR /&gt;BonusMonth=month(Hire_Date);&lt;BR /&gt;run;&lt;BR /&gt;data work.subset1;&lt;BR /&gt;set orion.sales;&lt;BR /&gt;Bonus=500;&lt;BR /&gt;Compensation=sum(Salary,Bonus);&lt;BR /&gt;BonusMonth=month(Hire_Date);&lt;BR /&gt;drop Salary;&lt;BR /&gt;run;&lt;BR /&gt;a. Yes&lt;BR /&gt;b. No&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Correct answer: a&lt;/P&gt;&lt;P&gt;Variables in the DROP statement are dropped during output, so they're available for calculations in the DATA step, even if they follow the statements that reference them.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If variables can still be used in the calculations, wouldn't that mean they still exist in the data set? Thanks much!&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jan 2016 17:16:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Drop-and-Keep-Question/m-p/241863#M44846</guid>
      <dc:creator>Durlov</dc:creator>
      <dc:date>2016-01-05T17:16:22Z</dc:date>
    </item>
    <item>
      <title>Re: Drop and Keep Question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Drop-and-Keep-Question/m-p/241865#M44847</link>
      <description>&lt;P&gt;Here's a simplified way of looking at the processing within a DATA step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Variables get copied from the input data set into memory.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Calculations get performed on the values in memory.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Results get copied from memory to the output data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When a DROP statement appears, that affects the final step, copying from memory to the output data set.&amp;nbsp; It is not necessary to copy all variables to the output.&amp;nbsp; Even a variable that was used in calculations can be dropped from the output data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are going to research this a bit more on your own, "in memory" would refer to the PDV (Program Data Vector).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good luck.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jan 2016 17:49:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Drop-and-Keep-Question/m-p/241865#M44847</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-01-05T17:49:56Z</dc:date>
    </item>
    <item>
      <title>Re: Drop and Keep Question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Drop-and-Keep-Question/m-p/241866#M44848</link>
      <description>&lt;P&gt;Your making this too hard.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There's data available to be used while creating a data set&lt;/P&gt;
&lt;P&gt;and then there's data that's contained in the final output set. They are two different things. Otherwise what's the point of a DROP statement, if the variable is still there in the end?&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jan 2016 17:49:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Drop-and-Keep-Question/m-p/241866#M44848</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-01-05T17:49:57Z</dc:date>
    </item>
    <item>
      <title>Re: Drop and Keep Question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Drop-and-Keep-Question/m-p/241876#M44849</link>
      <description>So just to be clear, after the "copying from memory to the output data set occurs", the variables are permanently dropped from the data set, right? For example, you can't drop a variable in a previous data step and then use that same variable for calculations in the next data step (assuming you're using the same data set for both data steps). Is that correct?</description>
      <pubDate>Tue, 05 Jan 2016 18:20:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Drop-and-Keep-Question/m-p/241876#M44849</guid>
      <dc:creator>Durlov</dc:creator>
      <dc:date>2016-01-05T18:20:40Z</dc:date>
    </item>
    <item>
      <title>Re: Drop and Keep Question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Drop-and-Keep-Question/m-p/241879#M44850</link>
      <description>That's correct &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Tue, 05 Jan 2016 18:23:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Drop-and-Keep-Question/m-p/241879#M44850</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-01-05T18:23:54Z</dc:date>
    </item>
    <item>
      <title>Re: Drop and Keep Question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Drop-and-Keep-Question/m-p/241884#M44851</link>
      <description>&lt;P&gt;Just to get nit-picky about a small detail, when a variable is dropped it never appears in the output data set.&amp;nbsp; "DROP" means when copying from memory to the output data set, don't bother to copy this variable.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jan 2016 18:36:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Drop-and-Keep-Question/m-p/241884#M44851</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-01-05T18:36:33Z</dc:date>
    </item>
    <item>
      <title>Re: Drop and Keep Question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Drop-and-Keep-Question/m-p/241888#M44852</link>
      <description>&lt;P&gt;Yeah, thanks much for your help. &lt;I&gt;I think I get it now (for some reason I can't remove the Italics). The 2nd question I posted confused me into thinking that the variable actually stays on, but just isn't displayed in the output.&lt;/I&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jan 2016 19:06:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Drop-and-Keep-Question/m-p/241888#M44852</guid>
      <dc:creator>Durlov</dc:creator>
      <dc:date>2016-01-05T19:06:12Z</dc:date>
    </item>
    <item>
      <title>Re: Drop and Keep Question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Drop-and-Keep-Question/m-p/242011#M44903</link>
      <description>&lt;P&gt;Out put data set will contain two variables&lt;/P&gt;
&lt;P&gt;1 + 1 (newly created variable) = 2&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jan 2016 12:28:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Drop-and-Keep-Question/m-p/242011#M44903</guid>
      <dc:creator>Tanmay</dc:creator>
      <dc:date>2016-01-06T12:28:28Z</dc:date>
    </item>
  </channel>
</rss>

