DATA Step, Macro, Functions and more

unable to read multiple files !!

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 97
Accepted Solution

unable to read multiple files !!


hi ,

I am  unable to import the multiple files ...form desktop.

i could not able to trace the error in the code .. please help..

data allu.import;
input ExternalNames $ 40.;
infile  filevar=ExternalNames end=Last;
     do until (last);
       input . . ;
       output;
    end;
datalines;

c:\Documents and Settings\alluraiah.ychv\Desktop\data1.txt
c:\Documents and Settings\alluraiah.ychv\Desktop\moredata.txt
c:\Documents and Settings\alluraiah.ychv\Desktop\fred.txt

;

Regards

ALLU


Accepted Solutions
Solution
‎02-11-2013 12:14 PM
Frequent Contributor
Posts: 97

Re: unable to read multiple files !!

thanks  Mr Tom...

View solution in original post


All Replies
Super Contributor
Posts: 578

Re: unable to read multiple files !!

data allu.import;
input ExternalNames $ 40.;
infile DUMMY filevar=ExternalNames end=Last;
     do until (last);
       input . . ;
       output;
    end;
datalines;

c:\Documents and Settings\alluraiah.ychv\Desktop\data1.txt
c:\Documents and Settings\alluraiah.ychv\Desktop\moredata.txt
c:\Documents and Settings\alluraiah.ychv\Desktop\fred.txt

;

Super User
Super User
Posts: 6,500

Re: unable to read multiple files !!

In addition to adding a fileref to the INFILE statement you should reset LAST variable to 0 after the DO loop.  Otherwise it will probably only read one line each from second file onward.

You should switch to a DO WHILE( NOT last) loop to prevent the data step from bombing when it hits an empty file.

Solution
‎02-11-2013 12:14 PM
Frequent Contributor
Posts: 97

Re: unable to read multiple files !!

thanks  Mr Tom...

Frequent Contributor
Posts: 97

Re: unable to read multiple files !!

thanks..

☑ This topic is SOLVED.

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

Discussion stats
  • 4 replies
  • 229 views
  • 6 likes
  • 3 in conversation