<?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 line specific lines which contains a specific value by id in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/keep-line-specific-lines-which-contains-a-specific-value-by-id/m-p/572542#M161571</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/192091"&gt;@ger15xxhcker&lt;/a&gt;&amp;nbsp;:&lt;/P&gt;
&lt;P&gt;It looks like a typical job for the DoW-loop:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test ;                              
  input id (date var1 var2) ($) ;        
  cards ;                                
1 20900101 abc abc2                      
2 20070102 cdf cdf2                      
2 20900101 jdk lao2                      
1 20110101 cds sxa                       
1 20150202 jui wsa                       
3 20900101 wer wes2                      
1 21000101 rte www                       
4 20190101 www rrr                       
;                                        
run ;                                    
                                         
proc sort data = test out = _test ;      
  by id ;                                
run ;                                    
                                         
data want (drop = _:) ;                  
  do _n_ = 1 by 1 until (last.id) ;      
    set _test ;                          
    by id ;                              
    if date ne "20900101" then continue ;
    output ;                             
    _flag = 1 ;                          
  end ;                                  
  do _n_ = 1 to _n_ ;                    
    set _test ;                          
    if not _flag then output ;           
  end ;                                  
run ;                                    
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Paul D.&lt;/P&gt;</description>
    <pubDate>Wed, 10 Jul 2019 21:52:36 GMT</pubDate>
    <dc:creator>hashman</dc:creator>
    <dc:date>2019-07-10T21:52:36Z</dc:date>
    <item>
      <title>keep line specific lines which contains a specific value by id</title>
      <link>https://communities.sas.com/t5/SAS-Programming/keep-line-specific-lines-which-contains-a-specific-value-by-id/m-p/572538#M161568</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a test data set. I&lt;SPAN&gt;f there is more than one identifier in the table and it is included 20900101 date then keep it that row. The rest are related to this ids delete it/drop it.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data;
input id date$ var1$ var2$;
datalines;
1 20900101 abc abc2
2 20070102 cdf cdf2
2 20900101 jdk lao2
1 20110101 cds sxa
1 20150202 jui wsa
3 20900101 wer wes2 
1 21000101 rte www
4 20190101 www rrr 
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so i'd like to this: (1. id contains 20900101 2. id contains 20900101 3. id contains 20900101 4. id not contains so keep it)&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data;
input id date$ var1$ var2$;
datalines;
1 20900101 abc abc2
2 20900101 jdk lao2
3 20900101 wer wes2 
4 20190101 www rrr 
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jul 2019 21:42:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/keep-line-specific-lines-which-contains-a-specific-value-by-id/m-p/572538#M161568</guid>
      <dc:creator>ger15xxhcker</dc:creator>
      <dc:date>2019-07-10T21:42:20Z</dc:date>
    </item>
    <item>
      <title>Re: keep line specific lines which contains a specific value by id</title>
      <link>https://communities.sas.com/t5/SAS-Programming/keep-line-specific-lines-which-contains-a-specific-value-by-id/m-p/572542#M161571</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/192091"&gt;@ger15xxhcker&lt;/a&gt;&amp;nbsp;:&lt;/P&gt;
&lt;P&gt;It looks like a typical job for the DoW-loop:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test ;                              
  input id (date var1 var2) ($) ;        
  cards ;                                
1 20900101 abc abc2                      
2 20070102 cdf cdf2                      
2 20900101 jdk lao2                      
1 20110101 cds sxa                       
1 20150202 jui wsa                       
3 20900101 wer wes2                      
1 21000101 rte www                       
4 20190101 www rrr                       
;                                        
run ;                                    
                                         
proc sort data = test out = _test ;      
  by id ;                                
run ;                                    
                                         
data want (drop = _:) ;                  
  do _n_ = 1 by 1 until (last.id) ;      
    set _test ;                          
    by id ;                              
    if date ne "20900101" then continue ;
    output ;                             
    _flag = 1 ;                          
  end ;                                  
  do _n_ = 1 to _n_ ;                    
    set _test ;                          
    if not _flag then output ;           
  end ;                                  
run ;                                    
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Paul D.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jul 2019 21:52:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/keep-line-specific-lines-which-contains-a-specific-value-by-id/m-p/572542#M161571</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2019-07-10T21:52:36Z</dc:date>
    </item>
    <item>
      <title>Re: keep line specific lines which contains a specific value by id</title>
      <link>https://communities.sas.com/t5/SAS-Programming/keep-line-specific-lines-which-contains-a-specific-value-by-id/m-p/572543#M161572</link>
      <description>&lt;P&gt;Thanks for your quick help!&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jul 2019 21:55:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/keep-line-specific-lines-which-contains-a-specific-value-by-id/m-p/572543#M161572</guid>
      <dc:creator>ger15xxhcker</dc:creator>
      <dc:date>2019-07-10T21:55:34Z</dc:date>
    </item>
    <item>
      <title>Re: keep line specific lines which contains a specific value by id</title>
      <link>https://communities.sas.com/t5/SAS-Programming/keep-line-specific-lines-which-contains-a-specific-value-by-id/m-p/572682#M161639</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id date$ var1$ var2$;
datalines;
1 20900101 abc abc2
2 20070102 cdf cdf2
2 20900101 jdk lao2
1 20110101 cds sxa
1 20150202 jui wsa
3 20900101 wer wes2 
1 21000101 rte www
4 20190101 www rrr 
;
run;
proc sql;
create table want as
select *
 from (select * from have group by id having count(*)&amp;gt;1)
  where date='20900101'
union all
select * from have group by id having count(*)=1;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 Jul 2019 12:15:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/keep-line-specific-lines-which-contains-a-specific-value-by-id/m-p/572682#M161639</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-07-11T12:15:55Z</dc:date>
    </item>
  </channel>
</rss>

