<?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: Delete first 5 nows for every dataset in WORK library in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Delete-first-5-rows-for-every-dataset-in-WORK-library/m-p/439522#M109677</link>
    <description>&lt;P&gt;I can't see what you are looking at.&amp;nbsp; You will have to show me the first 6 observations from one of the data sets for me to participate in this.&amp;nbsp; (I wouldn't need all the variables, but 3 or 4 would be necessary.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In general, it would not be a bad idea to do this as two separate steps ... combine all the data values as one step, and go back and rename variables as a second step.&amp;nbsp; As Art indicated, it can be automated but I can't see what you are looking at.&lt;/P&gt;</description>
    <pubDate>Thu, 22 Feb 2018 23:49:29 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2018-02-22T23:49:29Z</dc:date>
    <item>
      <title>Delete first 5 rows for every dataset in WORK library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-first-5-rows-for-every-dataset-in-WORK-library/m-p/439484#M109669</link>
      <description>&lt;P&gt;I want to append all the datasets I have in my WORK library together. They all have the same column names, but they start on row 6. I have too many datasets to delete first 5 rows with a macro. Is there a good shortcut I can use for this, similar to the code I use to append them to 1 dataset:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;PROC SQL;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;SELECT distinct MEMNAME INTO : MEMNAMES SEPARATED BY ' ' from dictionary.tables where libname='WORK';&lt;BR /&gt;quit;&lt;BR /&gt;&lt;BR /&gt;DATA full;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;SET &amp;amp;MEMNAMES.;&lt;BR /&gt;RUN;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Feb 2018 00:35:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-first-5-rows-for-every-dataset-in-WORK-library/m-p/439484#M109669</guid>
      <dc:creator>Melk</dc:creator>
      <dc:date>2018-02-23T00:35:21Z</dc:date>
    </item>
    <item>
      <title>Re: Delete first 5 nows for every dataset in WORK library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-first-5-rows-for-every-dataset-in-WORK-library/m-p/439491#M109671</link>
      <description>&lt;P&gt;Sure.&amp;nbsp; Let's start with something similar to what you used before:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;create table dslist as&lt;/P&gt;
&lt;P&gt;select memname from dictionary.tables&lt;/P&gt;
&lt;P&gt;where libname='WORK';&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instead of creating a macro variable, this creates a data set holding the names of your data sets.&amp;nbsp; Then construct and execute the rest of the program using:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;/P&gt;
&lt;P&gt;call execute ('data want; set ') ;&lt;/P&gt;
&lt;P&gt;do until (done);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; set dslist end=done;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; call execute (memname);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; call execute('(firstobs=6)');&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;call execute ('; run;') ;&lt;/P&gt;
&lt;P&gt;stop;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Feb 2018 22:00:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-first-5-rows-for-every-dataset-in-WORK-library/m-p/439491#M109671</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-02-22T22:00:46Z</dc:date>
    </item>
    <item>
      <title>Re: Delete first 5 nows for every dataset in WORK library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-first-5-rows-for-every-dataset-in-WORK-library/m-p/439498#M109672</link>
      <description>&lt;P&gt;Thank you - almost got it. It is selecting the first row as the variable names. Can I edit this to select row 5 as variable names (firstobs is still at 6)?&lt;/P&gt;</description>
      <pubDate>Thu, 22 Feb 2018 22:36:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-first-5-rows-for-every-dataset-in-WORK-library/m-p/439498#M109672</guid>
      <dc:creator>Melk</dc:creator>
      <dc:date>2018-02-22T22:36:22Z</dc:date>
    </item>
    <item>
      <title>Re: Delete first 5 nows for every dataset in WORK library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-first-5-rows-for-every-dataset-in-WORK-library/m-p/439519#M109675</link>
      <description>&lt;P&gt;If all of your files have the same variables, you could just modify&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;'s code as follows:&lt;/P&gt;
&lt;PRE&gt;data test1;
  input (col1-col3) ($);
  cards;
kjkj jkjk ljknl
kjcio doik roukg
kjor ytiukk lkjf
ruie eooik piijmf
item1 item2 item3
1 2 3
4 5 6
;

data test2;
  input (col1-col3) ($);
  cards;
kjkj jkjk ljknl
kjcio doik roukg
kjor ytiukk lkjf
ruie eooik piijmf
item1 item2 item3
7 8 9
2 2 2
;

data _null_;
  array namelist $32. col1-col3;
  set test1(firstobs=5 obs=5);
  length names $32000;
  do over namelist;
    names=catx(' ',names,vname(namelist),'=',vvalue(namelist));
  end;
  call symput('renames',names);
run;

proc sql;
  create table dslist as
    select memname from dictionary.tables
      where libname='WORK'
  ;
quit;

data _null_;
  call execute ('data want; set ') ;
  do until (done);
    set dslist end=done;
    call execute (memname);
    call execute("(firstobs=6 rename=(&amp;amp;renames.))");
  end;
  call execute ('; run;') ;
  stop;
run;
&lt;/PRE&gt;
&lt;P&gt;Of course, that would have to be expanded if the problem is more complex.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Feb 2018 23:29:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-first-5-rows-for-every-dataset-in-WORK-library/m-p/439519#M109675</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2018-02-22T23:29:51Z</dc:date>
    </item>
    <item>
      <title>Re: Delete first 5 nows for every dataset in WORK library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-first-5-rows-for-every-dataset-in-WORK-library/m-p/439522#M109677</link>
      <description>&lt;P&gt;I can't see what you are looking at.&amp;nbsp; You will have to show me the first 6 observations from one of the data sets for me to participate in this.&amp;nbsp; (I wouldn't need all the variables, but 3 or 4 would be necessary.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In general, it would not be a bad idea to do this as two separate steps ... combine all the data values as one step, and go back and rename variables as a second step.&amp;nbsp; As Art indicated, it can be automated but I can't see what you are looking at.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Feb 2018 23:49:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-first-5-rows-for-every-dataset-in-WORK-library/m-p/439522#M109677</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-02-22T23:49:29Z</dc:date>
    </item>
    <item>
      <title>Re: Delete first 5 nows for every dataset in WORK library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-first-5-rows-for-every-dataset-in-WORK-library/m-p/439523#M109678</link>
      <description>&lt;P&gt;This is a question the justifies use of global &lt;EM&gt;&lt;STRONG&gt;options firstobs=&lt;/STRONG&gt;&lt;/EM&gt;, as in:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
  SELECT distinct MEMNAME INTO : MEMNAMES SEPARATED BY ' ' from dictionary.tables where libname='WORK';
quit;

options firstobs=6;
DATA full;
    SET &amp;amp;MEMNAMES.;
RUN;
options firstobs=1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The firstobs=6 option will be applied to every data set subsequently being read in.&amp;nbsp; After the successful append, reset option to its default (firstobs=1).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Feb 2018 23:52:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-first-5-rows-for-every-dataset-in-WORK-library/m-p/439523#M109678</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-02-22T23:52:05Z</dc:date>
    </item>
    <item>
      <title>Re: Delete first 5 nows for every dataset in WORK library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-first-5-rows-for-every-dataset-in-WORK-library/m-p/439524#M109679</link>
      <description>&lt;P&gt;firstobs=6 is working but it is still labeling the columns based on some text in A1 and just default excel column letters B..C..D.... for the rest. firstobs=1 is not changing the column labels to variable names in row 5.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Feb 2018 00:13:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-first-5-rows-for-every-dataset-in-WORK-library/m-p/439524#M109679</guid>
      <dc:creator>Melk</dc:creator>
      <dc:date>2018-02-23T00:13:45Z</dc:date>
    </item>
    <item>
      <title>Re: Delete first 5 nows for every dataset in WORK library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-first-5-rows-for-every-dataset-in-WORK-library/m-p/439532#M109684</link>
      <description>Hello - I am a little unclear for the array - I need to input the names of the current column names?</description>
      <pubDate>Fri, 23 Feb 2018 00:48:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-first-5-rows-for-every-dataset-in-WORK-library/m-p/439532#M109684</guid>
      <dc:creator>Melk</dc:creator>
      <dc:date>2018-02-23T00:48:50Z</dc:date>
    </item>
    <item>
      <title>Re: Delete first 5 nows for every dataset in WORK library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-first-5-rows-for-every-dataset-in-WORK-library/m-p/439533#M109685</link>
      <description>&lt;P&gt;Yes! Instead of:&lt;/P&gt;
&lt;PRE&gt;  array namelist $32. col1-col3;
&lt;/PRE&gt;
&lt;P&gt;col1-col3 should be replaced with your actual variable names&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Feb 2018 00:54:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-first-5-rows-for-every-dataset-in-WORK-library/m-p/439533#M109685</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2018-02-23T00:54:04Z</dc:date>
    </item>
    <item>
      <title>Re: Delete first 5 nows for every dataset in WORK library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-first-5-rows-for-every-dataset-in-WORK-library/m-p/439536#M109688</link>
      <description>getting an error message at the second data _null_. Can you help me troubleshoot? THank you!&lt;BR /&gt;&lt;BR /&gt;ERROR 214-322: Variable name = is not valid.&lt;BR /&gt;&lt;BR /&gt;ERROR 23-7: Invalid value for the RENAME option.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;***error was given per log at the 2nd column name rename&lt;BR /&gt;&lt;BR /&gt;ERROR 79-322: Expecting a =.&lt;BR /&gt;</description>
      <pubDate>Fri, 23 Feb 2018 00:58:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-first-5-rows-for-every-dataset-in-WORK-library/m-p/439536#M109688</guid>
      <dc:creator>Melk</dc:creator>
      <dc:date>2018-02-23T00:58:27Z</dc:date>
    </item>
    <item>
      <title>Re: Delete first 5 nows for every dataset in WORK library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-first-5-rows-for-every-dataset-in-WORK-library/m-p/439539#M109691</link>
      <description>&lt;P&gt;Ah, it is because the actual variable names in line 5 have spaces...&lt;/P&gt;</description>
      <pubDate>Fri, 23 Feb 2018 01:02:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-first-5-rows-for-every-dataset-in-WORK-library/m-p/439539#M109691</guid>
      <dc:creator>Melk</dc:creator>
      <dc:date>2018-02-23T01:02:23Z</dc:date>
    </item>
    <item>
      <title>Re: Delete first 5 nows for every dataset in WORK library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-first-5-rows-for-every-dataset-in-WORK-library/m-p/439551#M109699</link>
      <description>&lt;P&gt;include the translate function to convert the spaces to underscores. e.g.:&lt;/P&gt;
&lt;PRE&gt;data test1;
  input (col1-col3) (&amp;amp;$);
  cards;
kjkj  jkjk  ljknl
kjcio  doik  roukg
kjor  ytiukk  lkjf
ruie  eooik  piijmf
item 1  item 2  item 3
1  2  3
4  5  6
;

data test2;
  input (col1-col3) (&amp;amp;$);
  cards;
kjkj  jkjk  ljknl
kjcio  doik  roukg
kjor  ytiukk  lkjf
ruie  eooik  piijmf
item 1  item 2  item 3
7  8  9
2  2  2
;

data _null_;
  array namelist $32. col1-col3;
  set test1(firstobs=5 obs=5);
  length names $32000;
  do over namelist;
    names=catx(' ',names,vname(namelist),'=',
     translate(strip(vvalue(namelist)),'_',' '));
  end;
  call symput('renames',names);
run;

%put &amp;amp;renames.;

proc sql;
  create table dslist as
    select memname from dictionary.tables
      where libname='WORK'
  ;
quit;

data _null_;
  call execute ('data want; set ') ;
  do until (done);
    set dslist end=done;
    call execute (memname);
    call execute("(firstobs=6 rename=(&amp;amp;renames.))");
  end;
  call execute ('; run;') ;
  stop;
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Feb 2018 01:29:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-first-5-rows-for-every-dataset-in-WORK-library/m-p/439551#M109699</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2018-02-23T01:29:18Z</dc:date>
    </item>
  </channel>
</rss>

