BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
hondahawkrider
Fluorite | Level 6

Have a script that works great

 

proc import 
   datafile="c:\temp\input.csv"
   replace
   /*
   out command below only keeps what var columns you need for data - missing vars
   represent empty columns 
   */
   out = data_read (keep = var1 var2 var4 var5 var11 var12)
   dbms=csv
   out=t2
   ;
   guessingrows=32767
   ;
   *getnames=yes - pulls the header names, only use if csv has headers 
   namerow will also tell you what line to get the names if necessary;
   getnames=no
   ;
   *Firstobs=9;
   *datarow tells you what line to start;
   datarow=9
   ;
   DELIMITER=' '
   ;
run ;
proc contents ;
run ;
proc print ;
run ;
proc export
   data=t2
   outfile="C:\temp\output.csv"
   dbms=csv
   replace
;
run ;

The problem is that the the input.csv file now contains the following statement

 

 " Elapsed: 00:14:43.61," at the end of the file

 

So I am looking for way to delete the last line or find a way to delete rows that beging with "elapsed"

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

Here is one possible solution: replace the first two lines of your script:

proc import 
   datafile="c:\temp\input.csv"

with

filename FT16F001 temp; 
data _null_; 
  infile "c:\temp\input.csv";
  file FT16F001;
  input; 
  if _infile_ eq: 'Elapsed' then stop; 
  put _infile_; 
run;
proc import datafile=FT16F001

Art, CEO, AnalystFinder.com

 

View solution in original post

1 REPLY 1
art297
Opal | Level 21

Here is one possible solution: replace the first two lines of your script:

proc import 
   datafile="c:\temp\input.csv"

with

filename FT16F001 temp; 
data _null_; 
  infile "c:\temp\input.csv";
  file FT16F001;
  input; 
  if _infile_ eq: 'Elapsed' then stop; 
  put _infile_; 
run;
proc import datafile=FT16F001

Art, CEO, AnalystFinder.com

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 2679 views
  • 1 like
  • 2 in conversation