<?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 without directly mention them or without DROP statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Drop-variables-without-directly-mention-them-or-without-DROP/m-p/674360#M203064</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/268199"&gt;@webart999ARM&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I don't say that il will not work. I'm just seeking a shorter solution.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Shorter? How about the solution from&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;&amp;nbsp;above?&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;If that's not it, explain the criteria you would want to use to determine what variables to drop.&lt;/P&gt;</description>
    <pubDate>Tue, 04 Aug 2020 14:09:44 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2020-08-04T14:09:44Z</dc:date>
    <item>
      <title>Drop variables without directly mention them or without DROP statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Drop-variables-without-directly-mention-them-or-without-DROP/m-p/674354#M203059</link>
      <description>&lt;P&gt;Hi there,&lt;BR /&gt;&lt;BR /&gt;Hope guys, you are doing well these days.&lt;BR /&gt;I have one simple question.&lt;BR /&gt;Yes, it's simple but could not manage to find an appropriate solution &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have below mentioned 36 variables, and want to drop them in my final data step.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="webart999ARM_0-1596548732016.png" style="width: 667px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/47913iADE34CAC95DF54A4/image-dimensions/667x105?v=v2" width="667" height="105" role="button" title="webart999ARM_0-1596548732016.png" alt="webart999ARM_0-1596548732016.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I think it'll be not accurate with just mention them in the drop statement.&lt;/P&gt;&lt;P&gt;Can anyone suggest another approach?&lt;BR /&gt;&lt;BR /&gt;Thank you in advance&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Aug 2020 13:54:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Drop-variables-without-directly-mention-them-or-without-DROP/m-p/674354#M203059</guid>
      <dc:creator>webart999ARM</dc:creator>
      <dc:date>2020-08-04T13:54:15Z</dc:date>
    </item>
    <item>
      <title>Re: Drop variables without directly mention them or without DROP statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Drop-variables-without-directly-mention-them-or-without-DROP/m-p/674355#M203060</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/268199"&gt;@webart999ARM&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi there,&lt;BR /&gt;&lt;BR /&gt;Hope guys, you are doing well these days.&lt;BR /&gt;I have one simple question.&lt;BR /&gt;Yes, it's simple but could not manage to find an appropriate solution &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have below mentioned 36 variables, and want to drop them in my final data step.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="webart999ARM_0-1596548732016.png" style="width: 667px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/47913iADE34CAC95DF54A4/image-dimensions/667x105?v=v2" width="667" height="105" role="button" title="webart999ARM_0-1596548732016.png" alt="webart999ARM_0-1596548732016.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But I think it'll be not accurate with just mention them in the drop statement.&lt;/P&gt;
&lt;P&gt;Can anyone suggest another approach?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;What do you mean "not accurate"? Why do you think the DROP statement will not work; the DROP statement does exactly what it is supposed to do.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Aug 2020 13:55:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Drop-variables-without-directly-mention-them-or-without-DROP/m-p/674355#M203060</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-08-04T13:55:42Z</dc:date>
    </item>
    <item>
      <title>Re: Drop variables without directly mention them or without DROP statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Drop-variables-without-directly-mention-them-or-without-DROP/m-p/674356#M203061</link>
      <description>&lt;P&gt;If they appear in that order, you can say&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;drop _9t_9a -- _7t_fb;&amp;nbsp; /* note the double dashes */&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or you could simply mention the variables that you want to keep in a keep statement. The others will be dropped.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Aug 2020 13:56:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Drop-variables-without-directly-mention-them-or-without-DROP/m-p/674356#M203061</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2020-08-04T13:56:48Z</dc:date>
    </item>
    <item>
      <title>Re: Drop variables without directly mention them or without DROP statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Drop-variables-without-directly-mention-them-or-without-DROP/m-p/674357#M203062</link>
      <description>&lt;P&gt;I don't say that il will not work. I'm just seeking a shorter solution.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Aug 2020 13:59:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Drop-variables-without-directly-mention-them-or-without-DROP/m-p/674357#M203062</guid>
      <dc:creator>webart999ARM</dc:creator>
      <dc:date>2020-08-04T13:59:54Z</dc:date>
    </item>
    <item>
      <title>Re: Drop variables without directly mention them or without DROP statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Drop-variables-without-directly-mention-them-or-without-DROP/m-p/674360#M203064</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/268199"&gt;@webart999ARM&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I don't say that il will not work. I'm just seeking a shorter solution.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Shorter? How about the solution from&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;&amp;nbsp;above?&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;If that's not it, explain the criteria you would want to use to determine what variables to drop.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Aug 2020 14:09:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Drop-variables-without-directly-mention-them-or-without-DROP/m-p/674360#M203064</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-08-04T14:09:44Z</dc:date>
    </item>
    <item>
      <title>Re: Drop variables without directly mention them or without DROP statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Drop-variables-without-directly-mention-them-or-without-DROP/m-p/674365#M203067</link>
      <description>&lt;P&gt;"&lt;SPAN&gt;drop _9t_9a -- _7t_fb;" it's an obviously shorter solution, but '--' can cause unexpected results after data update, I think you know what I'm talking about.&lt;BR /&gt;The solution for that could be to define variables in that exact order before the drop, but in that case, again we will have 36 variables mentioned in 'length' or 'retain' statement.&lt;BR /&gt;I will use 'keep' for now.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Aug 2020 14:20:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Drop-variables-without-directly-mention-them-or-without-DROP/m-p/674365#M203067</guid>
      <dc:creator>webart999ARM</dc:creator>
      <dc:date>2020-08-04T14:20:03Z</dc:date>
    </item>
    <item>
      <title>Re: Drop variables without directly mention them or without DROP statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Drop-variables-without-directly-mention-them-or-without-DROP/m-p/674376#M203071</link>
      <description>&lt;P&gt;Here is a reference that illustrates how to refer to variables and datasets in a short cut list:&lt;BR /&gt;&lt;A href="https://blogs.sas.com/content/iml/2018/05/29/6-easy-ways-to-specify-a-list-of-variables-in-sas.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2018/05/29/6-easy-ways-to-specify-a-list-of-variables-in-sas.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can short cut your references if you have a naming convention. The article above illustrates the methods to shorten a list of variables and make them more dynamic. You can drop all variables that start with _9T with the following line for example.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;drop _9T: ;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/268199"&gt;@webart999ARM&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;"&lt;SPAN&gt;drop _9t_9a -- _7t_fb;" it's an obviously shorter solution, but '--' can cause unexpected results after data update, I think you know what I'm talking about.&lt;BR /&gt;The solution for that could be to define variables in that exact order before the drop, but in that case, again we will have 36 variables mentioned in 'length' or 'retain' statement.&lt;BR /&gt;I will use 'keep' for now.&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Aug 2020 14:49:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Drop-variables-without-directly-mention-them-or-without-DROP/m-p/674376#M203071</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-08-04T14:49:38Z</dc:date>
    </item>
    <item>
      <title>Re: Drop variables without directly mention them or without DROP statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Drop-variables-without-directly-mention-them-or-without-DROP/m-p/674384#M203077</link>
      <description>&lt;P&gt;There are several ways of mentioning multiple variables in a DROP statement (or elsewhere):&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;EM&gt;drop _9T_AA--7T_FB&lt;/EM&gt; - drops the variables if they are in that order on the data step data vector&lt;/LI&gt;
&lt;LI&gt;&lt;EM&gt;drop _:&lt;/EM&gt; - drops all variables beginning with an underscore. I very often define temporary variables with an underscore first, and then use exactly that statement to drop them&lt;/LI&gt;
&lt;LI&gt;&lt;EM&gt;drop _9T_: _8T_: _3T_:&amp;nbsp;_7T_:&lt;/EM&gt; - a variation on the above, a bit more refined, should get all the variables mentioned&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;If none of these work for you, you may have to do some more advanced stuff. One is using a macro to define the exact names:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro droplist(prefixes,suffixes);
  %local i1 i2 w1;
  %do i1=1 %to %sysfunc(countw(&amp;amp;prefixes));
      %let w1=%scan(&amp;amp;prefixes,&amp;amp;i1);
      %do i2=1 %to %sysfunc(countw(&amp;amp;suffixes)); _&amp;amp;w1._%scan(&amp;amp;suffixes,&amp;amp;i2)%end;
      %end;
%mend;

data want;
  set have;
  drop %droplist(9T 8T 3T 7T,AA AB BA BB DA EB FB) _dummy xx p3;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I put in the extra variables in the DROP example, just to show how the macro can be used very flexibly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Aug 2020 15:08:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Drop-variables-without-directly-mention-them-or-without-DROP/m-p/674384#M203077</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2020-08-04T15:08:28Z</dc:date>
    </item>
    <item>
      <title>Re: Drop variables without directly mention them or without DROP statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Drop-variables-without-directly-mention-them-or-without-DROP/m-p/674388#M203080</link>
      <description>&lt;P&gt;Sounds like you want an easy text pattern generator.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
	length text $1024.;
	do i = 9,8,7,3;
		do j = 'AA','AB','BA','BB','CA','CB','DA','EB','FB';
			text = catx(' ',text,cats('_',i,'T_',j));
		end;
	end;
	call symputx('text',text);
run;

%put &amp;amp;=text;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Sure you can transform it to macro.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Aug 2020 15:19:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Drop-variables-without-directly-mention-them-or-without-DROP/m-p/674388#M203080</guid>
      <dc:creator>whymath</dc:creator>
      <dc:date>2020-08-04T15:19:51Z</dc:date>
    </item>
    <item>
      <title>Re: Drop variables without directly mention them or without DROP statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Drop-variables-without-directly-mention-them-or-without-DROP/m-p/674451#M203117</link>
      <description>Thank you all guys for your suggested methods.&lt;BR /&gt;I find some new techniques for me.&lt;BR /&gt;&lt;BR /&gt;Special thanks to &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/76464"&gt;@s_lassen&lt;/a&gt; for an advanced solution. I will try to understand the code you have sent &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;#bestcommunity</description>
      <pubDate>Tue, 04 Aug 2020 16:58:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Drop-variables-without-directly-mention-them-or-without-DROP/m-p/674451#M203117</guid>
      <dc:creator>webart999ARM</dc:creator>
      <dc:date>2020-08-04T16:58:59Z</dc:date>
    </item>
  </channel>
</rss>

