DATA Step, Macro, Functions and more

use first row as name and start the data from third row in proc import function

Accepted Solution Solved
Reply
Contributor
Posts: 73
Accepted Solution

use first row as name and start the data from third row in proc import function

Dear Everyone, 

 

I am importing text file to SAS format. I want to use first row as name and start the data from third row. I am using the following code. It is not happening:

 

proc import datafile='H:\Seminar Class\Banking Seminar\Data by me\Bank Call Report\FFIEC data\FFIEC CDR Call Bulk All Schedules 03312011/FFIEC CDR Call Bulk POR 03312011.txt'
out=POR0311 dbms=dlm replace;
datarow=2; delimiter='09'x;
run;


Accepted Solutions
Solution
‎06-11-2018 01:02 AM
Respected Advisor
Posts: 4,736

Re: use first row as name and start the data from third row in proc import function

[ Edited ]

@nazmul

If you want to read the data starting in row 3 then instruct SAS to do so by setting datarow=3

proc import datafile='c:\temp\test.txt'
  out=POR0311 
  dbms=dlm replace;
  datarow=3
  ;
  delimiter='09'x;
  getnames=yes;
  guessingrows=max;
run;

If Proc Import can't fully do what you need then you can also always copy/paste the generated data step from the log into a code window and then amend this data step as you need it. This gives you full flexibility.

View solution in original post


All Replies
Super User
Posts: 10,217

Re: use first row as name and start the data from third row in proc import function

Post the log. Anytime something "does not work", post the log. Use the {i} button to preserve formatting.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Regular Contributor
Posts: 158

Re: use first row as name and start the data from third row in proc import function

it says 'datarow=2', but you want to start at row 3. Usually it is not recommended to modify the data source but why not just remove the 2nd row from the txt file and run the code again?

--------------
blog: papersandprograms.com
Solution
‎06-11-2018 01:02 AM
Respected Advisor
Posts: 4,736

Re: use first row as name and start the data from third row in proc import function

[ Edited ]

@nazmul

If you want to read the data starting in row 3 then instruct SAS to do so by setting datarow=3

proc import datafile='c:\temp\test.txt'
  out=POR0311 
  dbms=dlm replace;
  datarow=3
  ;
  delimiter='09'x;
  getnames=yes;
  guessingrows=max;
run;

If Proc Import can't fully do what you need then you can also always copy/paste the generated data step from the log into a code window and then amend this data step as you need it. This gives you full flexibility.

Contributor
Posts: 73

Re: use first row as name and start the data from third row in proc import function

Thank you Patrick. Your code was really helpful for me Smiley Very Happy
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 196 views
  • 0 likes
  • 4 in conversation