<?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: keep statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/keep-statement/m-p/55088#M11735</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Only differnce is when it is applied.&lt;/P&gt;&lt;P&gt;If you use the KEEP= option on an input dataset then only those variables are loaded into the data step (or proc step) whereas when it is on the output dataset or the KEEP statement is used all of the variables are available during the step.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another place where which makes a difference is when using RENAME statement. The second datastep below will generate an error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;data one ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set sashelp.class;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; keep name age;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; rename age=age2;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data two (keep=name age);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set sashelp.class;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; rename age=age2;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 28 Nov 2011 14:54:12 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2011-11-28T14:54:12Z</dc:date>
    <item>
      <title>keep statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/keep-statement/m-p/55087#M11734</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is there any difference write a keep in option and datastep?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ashwini&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Nov 2011 10:55:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/keep-statement/m-p/55087#M11734</guid>
      <dc:creator>Ashwini</dc:creator>
      <dc:date>2011-11-28T10:55:48Z</dc:date>
    </item>
    <item>
      <title>Re: keep statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/keep-statement/m-p/55088#M11735</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Only differnce is when it is applied.&lt;/P&gt;&lt;P&gt;If you use the KEEP= option on an input dataset then only those variables are loaded into the data step (or proc step) whereas when it is on the output dataset or the KEEP statement is used all of the variables are available during the step.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another place where which makes a difference is when using RENAME statement. The second datastep below will generate an error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;data one ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set sashelp.class;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; keep name age;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; rename age=age2;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data two (keep=name age);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set sashelp.class;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; rename age=age2;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Nov 2011 14:54:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/keep-statement/m-p/55088#M11735</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2011-11-28T14:54:12Z</dc:date>
    </item>
    <item>
      <title>Re: keep statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/keep-statement/m-p/55089#M11736</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;And, to add to Tom's comments, when used as an option in a data or set statement, the drop, keep and rename statements are applied in alphabetical order (i.e., first drop, then keep, then rename).&amp;nbsp; Thus, using Tom's example, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data one;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set sashelp.class (keep=name age rename=(age=age2));&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;would work as the rename wouldn't take effect until AFTER the keep statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class="jive-code"&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Nov 2011 15:17:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/keep-statement/m-p/55089#M11736</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-11-28T15:17:02Z</dc:date>
    </item>
  </channel>
</rss>

