<?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 variables from a data set conditionally in SAS Data Science</title>
    <link>https://communities.sas.com/t5/SAS-Data-Science/drop-variables-from-a-data-set-conditionally/m-p/147017#M1464</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;This seems to work, but is it correct?&lt;/P&gt;&lt;P&gt;In SAS, how can I do the equivalent of:&lt;/P&gt;&lt;P&gt;data a;&lt;/P&gt;&lt;P&gt;set b;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if (somecondition = true) then do;&lt;/P&gt;&lt;P&gt;drop col2;&lt;/P&gt;&lt;P&gt;end;/*col2 is a column included in b*/&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 30 Jan 2015 20:25:53 GMT</pubDate>
    <dc:creator>eagles_dare13</dc:creator>
    <dc:date>2015-01-30T20:25:53Z</dc:date>
    <item>
      <title>drop variables from a data set conditionally</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/drop-variables-from-a-data-set-conditionally/m-p/147015#M1462</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In SAS, how can I do the equivalent of:&lt;/P&gt;&lt;P&gt;data a;&lt;/P&gt;&lt;P&gt;set b;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if (somecondition = true)&lt;/P&gt;&lt;P&gt;drop col2; /*col2 is a column included in b*/&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Jan 2015 20:20:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/drop-variables-from-a-data-set-conditionally/m-p/147015#M1462</guid>
      <dc:creator>eagles_dare13</dc:creator>
      <dc:date>2015-01-30T20:20:39Z</dc:date>
    </item>
    <item>
      <title>Re: drop variables from a data set conditionally</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/drop-variables-from-a-data-set-conditionally/m-p/147016#M1463</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can't easily. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What are you trying to do, perhaps there's another way?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Jan 2015 20:22:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/drop-variables-from-a-data-set-conditionally/m-p/147016#M1463</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-01-30T20:22:28Z</dc:date>
    </item>
    <item>
      <title>Re: drop variables from a data set conditionally</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/drop-variables-from-a-data-set-conditionally/m-p/147017#M1464</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;This seems to work, but is it correct?&lt;/P&gt;&lt;P&gt;In SAS, how can I do the equivalent of:&lt;/P&gt;&lt;P&gt;data a;&lt;/P&gt;&lt;P&gt;set b;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if (somecondition = true) then do;&lt;/P&gt;&lt;P&gt;drop col2;&lt;/P&gt;&lt;P&gt;end;/*col2 is a column included in b*/&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Jan 2015 20:25:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/drop-variables-from-a-data-set-conditionally/m-p/147017#M1464</guid>
      <dc:creator>eagles_dare13</dc:creator>
      <dc:date>2015-01-30T20:25:53Z</dc:date>
    </item>
    <item>
      <title>Re: drop variables from a data set conditionally</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/drop-variables-from-a-data-set-conditionally/m-p/147018#M1465</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your example doesn't do what you think when I supply data and a variety of conditions. But there are no syntax errors so it creates dataset A identical to B. Run proc compare on the two.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HINT: see what happens with If condition then drop col2; &amp;lt;= This is a syntax error with a "Statement is not valid or it is used out of proper order.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Drop is more of a global statement and isn't conditional.&lt;/P&gt;&lt;P&gt;This isn't how it works but consider this scenario:&lt;/P&gt;&lt;P&gt;Suppose the first record doesn't meet your condition. Then col2 is written to the output dataset. The column will now be present for all records regardless.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can exclude entire records from your output.&lt;/P&gt;&lt;P&gt;You can change the value of the variable for specific records.&lt;/P&gt;&lt;P&gt;The variable (column) is either present or not.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Jan 2015 21:11:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/drop-variables-from-a-data-set-conditionally/m-p/147018#M1465</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-01-30T21:11:35Z</dc:date>
    </item>
    <item>
      <title>Re: drop variables from a data set conditionally</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/drop-variables-from-a-data-set-conditionally/m-p/147019#M1466</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If I understood what you mean , you need two data step to get it. One is to pick up column name, the other is to drop column.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt; set class;&lt;/P&gt;&lt;P&gt; if name='Arthur' then call symputx('drop','age');&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set class;&lt;/P&gt;&lt;P&gt;drop &amp;amp;drop ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Xia Keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 31 Jan 2015 09:32:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/drop-variables-from-a-data-set-conditionally/m-p/147019#M1466</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-01-31T09:32:56Z</dc:date>
    </item>
    <item>
      <title>Re: drop variables from a data set conditionally</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/drop-variables-from-a-data-set-conditionally/m-p/147020#M1467</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If I understood what you mean , you need two data step to get it. One is to pick up column name, the other is to drop column.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt; set class;&lt;/P&gt;&lt;P&gt; if name='Arthur' then call symputx('drop','age');&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set class;&lt;/P&gt;&lt;P&gt;drop &amp;amp;drop ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Xia Keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 31 Jan 2015 09:50:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/drop-variables-from-a-data-set-conditionally/m-p/147020#M1467</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-01-31T09:50:33Z</dc:date>
    </item>
  </channel>
</rss>

