<?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/Drop variables based on one variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Keep-Drop-variables-based-on-one-variable/m-p/285358#M58322</link>
    <description>hi dallardw,&lt;BR /&gt;But I did put keep and drop in one data step before, i didn't recall any weird result though.... O_O&lt;BR /&gt;&lt;BR /&gt;Best,</description>
    <pubDate>Mon, 18 Jul 2016 20:04:30 GMT</pubDate>
    <dc:creator>Xiaoningdemao</dc:creator>
    <dc:date>2016-07-18T20:04:30Z</dc:date>
    <item>
      <title>Keep/Drop variables based on one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-Drop-variables-based-on-one-variable/m-p/285326#M58303</link>
      <description>&lt;P&gt;Dear All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a question about drop / keep variables. Now I have such a&amp;nbsp;data set:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;age gender height&amp;nbsp; &amp;nbsp;keep&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;drop&lt;/P&gt;&lt;P&gt;10&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 160&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; age&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gender&lt;/P&gt;&lt;P&gt;11&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;159 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;height&lt;/P&gt;&lt;P&gt;8&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;161&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So the first three variables are the observation info, and the last two variables listed the variables that I want to kee/drop. So the desired fresult would be:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;age&lt;/P&gt;&lt;P&gt;10&lt;/P&gt;&lt;P&gt;11&lt;/P&gt;&lt;P&gt;8&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can not use keep or drop because the actual data set contains almost 1000 variables, it is unrealistic to list them. I have been struggled with this for almost two days.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2016 18:28:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-Drop-variables-based-on-one-variable/m-p/285326#M58303</guid>
      <dc:creator>Xiaoningdemao</dc:creator>
      <dc:date>2016-07-18T18:28:24Z</dc:date>
    </item>
    <item>
      <title>Re: Keep/Drop variables based on one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-Drop-variables-based-on-one-variable/m-p/285338#M58306</link>
      <description>&lt;P&gt;No wonder you have been struggling. The first observation says keep age and drop gender. So where does height go?&lt;/P&gt;
&lt;P&gt;The second observation: It says keep nothing and drop height. Yet age is kept. And where does gender end up?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How is this supposed to work? How will you know what the values kept actually are?&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2016 18:56:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-Drop-variables-based-on-one-variable/m-p/285338#M58306</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-07-18T18:56:43Z</dc:date>
    </item>
    <item>
      <title>Re: Keep/Drop variables based on one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-Drop-variables-based-on-one-variable/m-p/285341#M58308</link>
      <description>Hi PG,&lt;BR /&gt;I meant the variable 'keep' stores the variable names I want to keep, 'drop' stores the variables I want to drop, we only need to use one of it. But i don't know which is easier to use. @PG Stats&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/14779"&gt;@PG&lt;/a&gt; Stats</description>
      <pubDate>Mon, 18 Jul 2016 19:17:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-Drop-variables-based-on-one-variable/m-p/285341#M58308</guid>
      <dc:creator>Xiaoningdemao</dc:creator>
      <dc:date>2016-07-18T19:17:10Z</dc:date>
    </item>
    <item>
      <title>Re: Keep/Drop variables based on one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-Drop-variables-based-on-one-variable/m-p/285347#M58312</link>
      <description>And since the 1000 variables we have here has both numerical and character variables I cannot simply transpose it.</description>
      <pubDate>Mon, 18 Jul 2016 19:37:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-Drop-variables-based-on-one-variable/m-p/285347#M58312</guid>
      <dc:creator>Xiaoningdemao</dc:creator>
      <dc:date>2016-07-18T19:37:51Z</dc:date>
    </item>
    <item>
      <title>Re: Keep/Drop variables based on one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-Drop-variables-based-on-one-variable/m-p/285349#M58314</link>
      <description>&lt;P&gt;Keep and Drop are not conditional. They affect the entire structure of a data set. A variable that is dropped is removed entirely from the dataset. If you use Keep, then only the referenced data is kept. If you use more than one Keep then all variables that appear on &lt;STRONG&gt;any&lt;/STRONG&gt; keep statement are in the final data:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Keep age;&lt;/P&gt;
&lt;P&gt;Keep height;&lt;/P&gt;
&lt;P&gt;means the only variables in the result set will be age and height.&lt;/P&gt;
&lt;P&gt;And from the online help for the Keep statement:&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="strong"&gt;Note:&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Do not use both the KEEP and DROP statements within the same DATA step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It may be easier to use WHERE clauses in other steps to select records with desired properties. With 1000 variables in your data that may be difficult.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2016 19:47:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-Drop-variables-based-on-one-variable/m-p/285349#M58314</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-07-18T19:47:58Z</dc:date>
    </item>
    <item>
      <title>Re: Keep/Drop variables based on one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-Drop-variables-based-on-one-variable/m-p/285351#M58316</link>
      <description>&lt;P&gt;This is a really weird data structure.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I I would use a previous step to pull names into a macro variable and execute it. I do wonder if going back a few steps would help this process.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc SQL noprint;
Select keep into :keep_list separated by ' '
From have;
Quit;


Data want;
Set have;

Keep &amp;amp;keep_list;
Run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Jul 2016 19:50:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-Drop-variables-based-on-one-variable/m-p/285351#M58316</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-07-18T19:50:46Z</dc:date>
    </item>
    <item>
      <title>Re: Keep/Drop variables based on one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-Drop-variables-based-on-one-variable/m-p/285352#M58317</link>
      <description>&lt;P&gt;Your also aware of variable shortcut lists I assume?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrcon/68089/HTML/default/viewer.htm#p0wphcpsfgx6o7n1sjtqzizp1n39.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrcon/68089/HTML/default/viewer.htm#p0wphcpsfgx6o7n1sjtqzizp1n39.htm&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2016 19:51:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-Drop-variables-based-on-one-variable/m-p/285352#M58317</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-07-18T19:51:51Z</dc:date>
    </item>
    <item>
      <title>Re: Keep/Drop variables based on one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-Drop-variables-based-on-one-variable/m-p/285356#M58320</link>
      <description>Dear Reeza,&lt;BR /&gt;Thank you very much! This is exactly what I want!!&lt;BR /&gt;Best,&lt;BR /&gt;</description>
      <pubDate>Mon, 18 Jul 2016 20:02:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-Drop-variables-based-on-one-variable/m-p/285356#M58320</guid>
      <dc:creator>Xiaoningdemao</dc:creator>
      <dc:date>2016-07-18T20:02:28Z</dc:date>
    </item>
    <item>
      <title>Re: Keep/Drop variables based on one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-Drop-variables-based-on-one-variable/m-p/285358#M58322</link>
      <description>hi dallardw,&lt;BR /&gt;But I did put keep and drop in one data step before, i didn't recall any weird result though.... O_O&lt;BR /&gt;&lt;BR /&gt;Best,</description>
      <pubDate>Mon, 18 Jul 2016 20:04:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-Drop-variables-based-on-one-variable/m-p/285358#M58322</guid>
      <dc:creator>Xiaoningdemao</dc:creator>
      <dc:date>2016-07-18T20:04:30Z</dc:date>
    </item>
    <item>
      <title>Re: Keep/Drop variables based on one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-Drop-variables-based-on-one-variable/m-p/285385#M58336</link>
      <description>No, I didn't. But this is very helpful as well! Thanks again.&lt;BR /&gt;&lt;BR /&gt;Best,</description>
      <pubDate>Mon, 18 Jul 2016 21:45:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-Drop-variables-based-on-one-variable/m-p/285385#M58336</guid>
      <dc:creator>Xiaoningdemao</dc:creator>
      <dc:date>2016-07-18T21:45:46Z</dc:date>
    </item>
  </channel>
</rss>

