<?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 Delete the second observation in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Delete-the-second-observation/m-p/594583#M170849</link>
    <description>&lt;PRE&gt;%macro clean();
%do i =1 %to 8;
data d_clean&amp;amp;i;
set dsn&amp;amp;i;
%if _n_ = 1 %then %delete;
%run;
%end;
%mend clean;

%clean()&lt;/PRE&gt;&lt;P&gt;I have a bunch of CSV files with similar names. After I read them in, I want to get rid of the second observations from those files. I wrote the macro (pasted above, which was hoped to do the loop work pasted below) to do it. However, I didn't get my result. Can anybody help?&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data clean_1; set dsn1; if _n_ = 1 then delete;run;
data clean_2; set dsn2; if _n_ = 1 then delete;run;
data clean_3; set dsn3; if _n_ = 1 then delete;run;
.....&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;</description>
    <pubDate>Mon, 07 Oct 2019 23:26:00 GMT</pubDate>
    <dc:creator>maxjiang6999</dc:creator>
    <dc:date>2019-10-07T23:26:00Z</dc:date>
    <item>
      <title>Delete the second observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-the-second-observation/m-p/594583#M170849</link>
      <description>&lt;PRE&gt;%macro clean();
%do i =1 %to 8;
data d_clean&amp;amp;i;
set dsn&amp;amp;i;
%if _n_ = 1 %then %delete;
%run;
%end;
%mend clean;

%clean()&lt;/PRE&gt;&lt;P&gt;I have a bunch of CSV files with similar names. After I read them in, I want to get rid of the second observations from those files. I wrote the macro (pasted above, which was hoped to do the loop work pasted below) to do it. However, I didn't get my result. Can anybody help?&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data clean_1; set dsn1; if _n_ = 1 then delete;run;
data clean_2; set dsn2; if _n_ = 1 then delete;run;
data clean_3; set dsn3; if _n_ = 1 then delete;run;
.....&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;</description>
      <pubDate>Mon, 07 Oct 2019 23:26:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-the-second-observation/m-p/594583#M170849</guid>
      <dc:creator>maxjiang6999</dc:creator>
      <dc:date>2019-10-07T23:26:00Z</dc:date>
    </item>
    <item>
      <title>Re: Delete the second observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-the-second-observation/m-p/594589#M170854</link>
      <description>&lt;P&gt;If I understand you then&lt;/P&gt;
&lt;PRE&gt;if _n_ = 1 then delete;&lt;/PRE&gt;
&lt;P&gt;means to delete the first row. Replace the 1 into 2 in order to delete the second row in the file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I'm wrong - please explain' what do you mean by "&lt;STRONG&gt;&lt;SPAN&gt;&amp;nbsp;I didn't get my result.&lt;/SPAN&gt;&lt;/STRONG&gt;" ? and what issues did you have ?&lt;/P&gt;</description>
      <pubDate>Tue, 08 Oct 2019 01:06:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-the-second-observation/m-p/594589#M170854</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2019-10-08T01:06:40Z</dc:date>
    </item>
    <item>
      <title>Re: Delete the second observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-the-second-observation/m-p/594591#M170856</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/283179"&gt;@maxjiang6999&lt;/a&gt;&amp;nbsp;wrote:
&lt;P class="1570499299179"&gt;....&lt;/P&gt;
I have a bunch of CSV files with similar names. After I read them in, I want to get rid of the second observations from those files.
&lt;P class="1570499314615"&gt;....&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Then why do you read this 2nd line from the .csv into SAS at all? Why not skip it while reading instead of post processing your SAS tables.&lt;/P&gt;
&lt;P&gt;If you provide a bit more detail what you have and what you need then I'm certain there will be a solution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Oct 2019 01:50:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-the-second-observation/m-p/594591#M170856</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-10-08T01:50:28Z</dc:date>
    </item>
    <item>
      <title>Re: Delete the second observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-the-second-observation/m-p/594604#M170865</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/283179"&gt;@maxjiang6999&lt;/a&gt;:&lt;/P&gt;
&lt;P&gt;There's no need to completely reread and rewrite each file just to delete one and the same observations from each. Simply modify the original files to mark the observations you want for deletion. When you reference thus modified files downstream for reading, only the non-marked observations will be read.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dsn_1 dsn_2 dsn_3 ;                                                                                                                                                                                                                                        
  do key = 1 to 5 ;                                                                                                                                                                                                                                             
    data = key * 1001 ;                                                                                                                                                                                                                                         
    output ;                                                                                                                                                                                                                                                    
  end ;                                                                                                                                                                                                                                                         
run ;                                                                                                                                                                                                                                                           
                                                                                                                                                                                                                                                                
%macro clean (N_del=, prefix=, N_files=) ;                                                                                                                                                                                                                      
  %local i ;                                                                                                                                                                                                                                                    
  %do i = 1 %to &amp;amp;N_files ;                                                                                                                                                                                                                                      
    data &amp;amp;prefix&amp;amp;i ;                                                                                                                                                                                                                                            
      p = &amp;amp;N_del ;                                                                                                                                                                                                                                              
      modify &amp;amp;prefix&amp;amp;i point = p ;                                                                                                                                                                                                                              
      remove ;                                                                                                                                                                                                                                                  
      stop ;                                                                                                                                                                                                                                                    
    run ;                                                                                                                                                                                                                                                       
  %end ;                                                                                                                                                                                                                                                        
%mend ;                                                                                                                                                                                                                                                         
                                                                                                                                                                                                                                                                
%clean (N_del=2, prefix=dsn_, N_files=3)                                                                                                                                                                                                                        
                                                                                                                                                                                                                                                                
/* just checking */                                                                                                                                                                                                                                             
data _null_ ;                                                                                                                                                                                                                                                   
  set dsn_1 dsn_2 dsn_3 ;                                                                                                                                                                                                                                       
run ;                       
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;As you'll see in "just checking", the observations marked for deletion by the macro aren't read in.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Paul D.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Oct 2019 03:08:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-the-second-observation/m-p/594604#M170865</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2019-10-08T03:08:29Z</dc:date>
    </item>
    <item>
      <title>Re: Delete the second observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-the-second-observation/m-p/594789#M170974</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/283179"&gt;@maxjiang6999&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;PRE&gt;%macro clean();
%do i =1 %to 8;
data d_clean&amp;amp;i;
set dsn&amp;amp;i;
%if _n_ = 1 %then %delete;
%run;
%end;
%mend clean;

%clean()&lt;/PRE&gt;
&lt;P&gt;I have a bunch of CSV files with similar names. After I read them in, I want to get rid of the second observations from those files. I wrote the macro (pasted above, which was hoped to do the loop work pasted below) to do it. However, I didn't get my result. Can anybody help?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data clean_1; set dsn1; if _n_ = 1 then delete;run;
data clean_2; set dsn2; if _n_ = 1 then delete;run;
data clean_3; set dsn3; if _n_ = 1 then delete;run;
.....&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Prevent don't fix: Read the data files with FIRSTOBS=3.&lt;/P&gt;
&lt;P&gt;Unless you are trusting proc import to read multiple files as needed.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Oct 2019 15:48:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-the-second-observation/m-p/594789#M170974</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-10-08T15:48:09Z</dc:date>
    </item>
  </channel>
</rss>

