<?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: if you have NA  in all character variables then you should delete that record in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/if-you-have-NA-in-all-character-variables-then-you-should-delete/m-p/613426#M179138</link>
    <description>Define an array over _character_ and iterate through it to set a flag variable; if flag is set at the end of the loop, keep the observation. &lt;BR /&gt;</description>
    <pubDate>Sun, 22 Dec 2019 07:25:24 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2019-12-22T07:25:24Z</dc:date>
    <item>
      <title>if you have NA  in all character variables then you should delete that record</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-you-have-NA-in-all-character-variables-then-you-should-delete/m-p/613425#M179137</link>
      <description>&lt;P&gt;data abc;&lt;BR /&gt;input col1 $ col2 col3 col4 $ Col5 $;&lt;BR /&gt;datalines;&lt;BR /&gt;NA 10 20 NA Hi&lt;BR /&gt;NA 11 22 NA NA&lt;BR /&gt;NA 12 13 NA ho&lt;BR /&gt;NA 16 22 BA jj&lt;BR /&gt;10 20 17 NA NA&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so only second row satisfies...&lt;/P&gt;&lt;P&gt;refrain from hard coding...&lt;/P&gt;&lt;P&gt;no hard coding please i.e. mention of columns. this is simple example, what if you had 100 columns;;&lt;/P&gt;</description>
      <pubDate>Sun, 22 Dec 2019 06:45:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-you-have-NA-in-all-character-variables-then-you-should-delete/m-p/613425#M179137</guid>
      <dc:creator>Saikiran_Mamidi</dc:creator>
      <dc:date>2019-12-22T06:45:08Z</dc:date>
    </item>
    <item>
      <title>Re: if you have NA  in all character variables then you should delete that record</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-you-have-NA-in-all-character-variables-then-you-should-delete/m-p/613426#M179138</link>
      <description>Define an array over _character_ and iterate through it to set a flag variable; if flag is set at the end of the loop, keep the observation. &lt;BR /&gt;</description>
      <pubDate>Sun, 22 Dec 2019 07:25:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-you-have-NA-in-all-character-variables-then-you-should-delete/m-p/613426#M179138</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-12-22T07:25:24Z</dc:date>
    </item>
    <item>
      <title>Re: if you have NA  in all character variables then you should delete that record</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-you-have-NA-in-all-character-variables-then-you-should-delete/m-p/613429#M179139</link>
      <description>can i get the code if possible.many thanks</description>
      <pubDate>Sun, 22 Dec 2019 10:26:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-you-have-NA-in-all-character-variables-then-you-should-delete/m-p/613429#M179139</guid>
      <dc:creator>Saikiran_Mamidi</dc:creator>
      <dc:date>2019-12-22T10:26:23Z</dc:date>
    </item>
    <item>
      <title>Re: if you have NA  in all character variables then you should delete that record</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-you-have-NA-in-all-character-variables-then-you-should-delete/m-p/613433#M179140</link>
      <description>&lt;P&gt;what have you tried?&amp;nbsp; everyone wants code to be provided for them without learning......&lt;/P&gt;
&lt;P&gt;Coding is more than just taking someone else's code and using it in you requirements.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 22 Dec 2019 13:12:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-you-have-NA-in-all-character-variables-then-you-should-delete/m-p/613433#M179140</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2019-12-22T13:12:13Z</dc:date>
    </item>
    <item>
      <title>Re: if you have NA  in all character variables then you should delete that record</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-you-have-NA-in-all-character-variables-then-you-should-delete/m-p/613435#M179141</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/304446"&gt;@Saikiran_Mamidi&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;can i get the code if possible.many thanks&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Learn by doing, and reading the documentation:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lestmtsref&amp;amp;docsetTarget=p08do6szetrxe2n136ush727sbuo.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;ARRAY Statement&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lestmtsref&amp;amp;docsetTarget=p1cydk5fq0u4bfn1xfbjt7w1c7lu.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;DO Statement: Iterative&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lestmtsref&amp;amp;docsetTarget=p1cxl8ifdt8u0gn12wqbji8o5fq1.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;IF Statement: Subsetting&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 22 Dec 2019 13:42:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-you-have-NA-in-all-character-variables-then-you-should-delete/m-p/613435#M179141</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-12-22T13:42:47Z</dc:date>
    </item>
    <item>
      <title>Re: if you have NA  in all character variables then you should delete that record</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-you-have-NA-in-all-character-variables-then-you-should-delete/m-p/613437#M179142</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/304446"&gt;@Saikiran_Mamidi&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can try this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- the array '_char' contains all character variables.&lt;/P&gt;
&lt;P&gt;- a counter is initiated (count = 0);&lt;/P&gt;
&lt;P&gt;- each time a variable of the array is equal to "NA", 1 is added to the counter&lt;/P&gt;
&lt;P&gt;-&amp;gt; so the counter, at the end, contains the number of character variable equal to 'NA'.&lt;/P&gt;
&lt;P&gt;Then , the value of this counter is compared to the number of variables in the array (= the dimension of the array represented by dim(array), which is equal to 3 in your example)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
	set abc;
	array _char(*) _character_;
	count = 0;
	do i=1 to dim(_char);
		if _char(i) = "NA" then count+1;
	end;
	if count = dim(_char) then delete;
	drop i count;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 22 Dec 2019 15:41:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-you-have-NA-in-all-character-variables-then-you-should-delete/m-p/613437#M179142</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2019-12-22T15:41:13Z</dc:date>
    </item>
    <item>
      <title>Re: if you have NA  in all character variables then you should delete that record</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-you-have-NA-in-all-character-variables-then-you-should-delete/m-p/613457#M179154</link>
      <description>&lt;P&gt;Why do the variables have NA in them to begin with?&amp;nbsp; What if the variable has a valid value of NA? Perhaps it is storing the abbreviation for sodium. Or it has a person's last name.&lt;/P&gt;</description>
      <pubDate>Sun, 22 Dec 2019 22:20:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-you-have-NA-in-all-character-variables-then-you-should-delete/m-p/613457#M179154</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-12-22T22:20:44Z</dc:date>
    </item>
    <item>
      <title>Re: if you have NA  in all character variables then you should delete that record</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-you-have-NA-in-all-character-variables-then-you-should-delete/m-p/613744#M179289</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;: NA = Not Applicable, I'd guess.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Dec 2019 16:10:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-you-have-NA-in-all-character-variables-then-you-should-delete/m-p/613744#M179289</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2019-12-24T16:10:40Z</dc:date>
    </item>
    <item>
      <title>Re: if you have NA  in all character variables then you should delete that record</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-you-have-NA-in-all-character-variables-then-you-should-delete/m-p/613767#M179300</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/304446"&gt;@Saikiran_Mamidi&lt;/a&gt;:&lt;/P&gt;
&lt;P&gt;This should do it:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;                                                                                                                             
  input (col1-col5) ($) ;                                                                                                               
  cards ;                                                                                                                               
NA 10 20 NA Hi                                                                                                                          
NA 11 22 NA NA                                                                                                                          
NA NA NA NA NA                                                                                                                          
NA 12 13 NA ho                                                                                                                          
NA 16 22 BA jj                                                                                                                          
10 20 17 NA NA                                                                                                                          
;                                                                                                                                       
run ;                                                                                                                                   
                                                                                                                                        
data want ;                                                                                                                             
  set have ;                                                                                                                            
  array col col: ;                                                                                                                      
  if count (cats (of col:), "NA") &amp;lt; dim (col) ;                                                                                         
run ;              
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Bear in mind, however, that if combined length of the COL variables should exceed 32767, there would be not enough CAT buffer length to accommodate the internal concatenation. That's why an array approach, though less elegant and more verbose, is more robust:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want (drop = _:) ;                                                                                                                 
  set have ;                                                                                                                            
  retain _stop "" ;                                                                                                                     
  array col[*] col: _stop ;                                                                                                             
  do _i = 1 by 1 until (col[_i] ne "NA") ;                                                                                              
  end ;                                                                                                                                 
  if _i &amp;lt; dim (col) - 1 ;                                                                                                               
run ;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note how the sentinel _STOP is made use of to save one key comparison in each iteration of the loop - the trick termed by D. Knuth "quick sequential search".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Paul D.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Dec 2019 17:58:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-you-have-NA-in-all-character-variables-then-you-should-delete/m-p/613767#M179300</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2019-12-24T17:58:09Z</dc:date>
    </item>
  </channel>
</rss>

