<?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 and drop statement in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Keep-and-drop-statement/m-p/621967#M19692</link>
    <description>&lt;P&gt;Try these versions, with the DROP dataset option:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have (drop=PT);
  PT2 = PT;
run;


data want (drop=PT);
  set have;
  PT2 = PT;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 03 Feb 2020 15:58:43 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2020-02-03T15:58:43Z</dc:date>
    <item>
      <title>Keep and drop statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Keep-and-drop-statement/m-p/621930#M19679</link>
      <description>&lt;P&gt;Hi everyone,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a question which has confused me for a while. As I know,&amp;nbsp;there are two types of DATA step statements: compile time statements and execution time statements. Compile time statements run prior to execution time statements and KEEPand DROP statement are compile time statement. Please see an example below. Let's say I have a dataset containing a PT column. If the DROP statement runs first in the compile phase, which means PT column would be dropped first and thus the assignment statement cannot be executed. However, why the data step below can run without error?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;&amp;nbsp; set have;&lt;BR /&gt;&amp;nbsp; drop PT;&lt;BR /&gt;&amp;nbsp; PT2 = PT;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Feb 2020 13:18:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Keep-and-drop-statement/m-p/621930#M19679</guid>
      <dc:creator>Amo89tw</dc:creator>
      <dc:date>2020-02-03T13:18:23Z</dc:date>
    </item>
    <item>
      <title>Re: Keep and drop statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Keep-and-drop-statement/m-p/621931#M19680</link>
      <description>&lt;P&gt;The &lt;A href="https://documentation.sas.com/?cdcId=pgmmvacdc&amp;amp;cdcVersion=9.4&amp;amp;docsetId=lestmtsref&amp;amp;docsetTarget=n1capr0s7tilbvn1lypdshkgpaip.htm&amp;amp;locale=en" target="_self"&gt;documentation&lt;/A&gt; makes this very clear.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;The DROP statement applies to all the SAS data sets that are created within the same DATA step and can appear anywhere in the step. The variables in the DROP statement are available for processing in the DATA step.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Mon, 03 Feb 2020 13:29:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Keep-and-drop-statement/m-p/621931#M19680</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-02-03T13:29:41Z</dc:date>
    </item>
    <item>
      <title>Re: Keep and drop statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Keep-and-drop-statement/m-p/621933#M19682</link>
      <description>&lt;P&gt;I think of it as the variables in the drop statement are flagged for dropping but are dropped only after data processing.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Feb 2020 13:39:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Keep-and-drop-statement/m-p/621933#M19682</guid>
      <dc:creator>unison</dc:creator>
      <dc:date>2020-02-03T13:39:40Z</dc:date>
    </item>
    <item>
      <title>Re: Keep and drop statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Keep-and-drop-statement/m-p/621938#M19685</link>
      <description>Thank you Paige. I was wondering why this is the case. Thanks again.</description>
      <pubDate>Mon, 03 Feb 2020 13:51:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Keep-and-drop-statement/m-p/621938#M19685</guid>
      <dc:creator>Amo89tw</dc:creator>
      <dc:date>2020-02-03T13:51:20Z</dc:date>
    </item>
    <item>
      <title>Re: Keep and drop statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Keep-and-drop-statement/m-p/621939#M19686</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/310253"&gt;@Amo89tw&lt;/a&gt;, the &lt;FONT face="courier new,courier"&gt;drop&lt;/FONT&gt; statement is used to instruct SAS which variables are not to be part of the output data set. It does &lt;STRONG&gt;not&lt;/STRONG&gt; prevent the variables from being used within the data step if they have already been read in or created in the data step. This is why your variable &lt;FONT face="courier new,courier"&gt;PT&lt;/FONT&gt; can be used in an assignment and does not cause an error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards,&lt;/P&gt;
&lt;P&gt;Amir.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Feb 2020 13:54:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Keep-and-drop-statement/m-p/621939#M19686</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2020-02-03T13:54:40Z</dc:date>
    </item>
    <item>
      <title>Re: Keep and drop statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Keep-and-drop-statement/m-p/621941#M19687</link>
      <description>&lt;P&gt;Thanks,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/22588"&gt;@Amir&lt;/a&gt;. Do you mean the assignment statement is actually processed prior to the drop statement?&amp;nbsp;I came across this article (please see the link below). “During this compilation phase, the compiler checks code syntax, sets up the PDV and executes certain statements like KEEP and DROP.” This is why I am curious about what happens behind the scene. Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.pharmasug.org/proceedings/2015/BB/PharmaSUG-2015-BB15.pdf" target="_blank"&gt;https://www.pharmasug.org/proceedings/2015/BB/PharmaSUG-2015-BB15.pdf&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Feb 2020 14:06:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Keep-and-drop-statement/m-p/621941#M19687</guid>
      <dc:creator>Amo89tw</dc:creator>
      <dc:date>2020-02-03T14:06:26Z</dc:date>
    </item>
    <item>
      <title>Re: Keep and drop statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Keep-and-drop-statement/m-p/621947#M19689</link>
      <description>&lt;P&gt;Thanks,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/270457"&gt;@unison&lt;/a&gt;&amp;nbsp;. if so, it makes sense to me. Many thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Feb 2020 14:16:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Keep-and-drop-statement/m-p/621947#M19689</guid>
      <dc:creator>Amo89tw</dc:creator>
      <dc:date>2020-02-03T14:16:54Z</dc:date>
    </item>
    <item>
      <title>Re: Keep and drop statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Keep-and-drop-statement/m-p/621950#M19690</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/310253"&gt;@Amo89tw&lt;/a&gt;, the assignment statement is &lt;STRONG&gt;not&lt;/STRONG&gt; executed before the drop statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As the link you provided explains, the drop statement affects the structure (PDV) of the output data set, i.e., which variables are &lt;STRONG&gt;not&lt;/STRONG&gt; going to be output, but this doesn't prevent them from being used in the statements in the data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Dropping a variable doesn't mean it cannot be used in the data step. Dropping a variable just means it won't appear in the output data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards,&lt;/P&gt;
&lt;P&gt;Amir.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Feb 2020 14:44:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Keep-and-drop-statement/m-p/621950#M19690</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2020-02-03T14:44:55Z</dc:date>
    </item>
    <item>
      <title>Re: Keep and drop statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Keep-and-drop-statement/m-p/621967#M19692</link>
      <description>&lt;P&gt;Try these versions, with the DROP dataset option:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have (drop=PT);
  PT2 = PT;
run;


data want (drop=PT);
  set have;
  PT2 = PT;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 03 Feb 2020 15:58:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Keep-and-drop-statement/m-p/621967#M19692</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-02-03T15:58:43Z</dc:date>
    </item>
  </channel>
</rss>

