LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (April 1996, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 4 Apr 1996 16:03:04 -0500
Reply-To:     Ken Hardy 20 Manning Hall <khardy@FROSTY.IRSS.UNC.EDU>
Sender:       "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From:         Ken Hardy 20 Manning Hall <khardy@FROSTY.IRSS.UNC.EDU>
Subject:      Re: Sequentially processing multiple datasets?
Comments: To: "John E. Bentley" <bentleyj@IX.NETCOM.COM>
In-Reply-To:  <4jpqhq$>

On Tue, 2 Apr 1996, John E. Bentley wrote:

> I need to find a social security number that is in one of a number of > external datasets. How do I read the datasets sequentially in the > same data step, check for the ssn, and then stop reading when the ssn > is found? Perhaps I'm stuck because I see it along the lines of > processing an array and my thinking is stuck on that track. > > Can someone sketch out a do-loop for me? Thanks in advance for the > help. > John E. Bentley > Chicago, IL, USA > ----------------------------------- > Send lawyers, guns, and money. >


I'm assuming you mean that the ssn you're looking for occurs only once in all the files.

Something like the following should work. The trick is the FILEVAR option on the second INFILE statement. This strategy can be used for a variety of situations where you have to process a number of filenames.

The file 'filenames.txt' contains a complete listing of the names of all the files you need to check for ssn. If there were just a few file names you could not use a file, omit the INFILE statement and list the file names after a CARDS; statement.

(This example is off a UNIX machine and you could use the PIPE option on the first INFILE statement. Under other OS's this would not be possible so I use a file here as the most general case.)

DATA _NULL_ ; /* Don't build a dataset */

INFILE '~/filenames.txt' ; INPUT filename $char80. ; /* read a file name */ /* longest filename is 80 */ /* your length may vary */

end=0; /* now process records in each file */ DO UNTIL (end) ; INFILE ssn FILEVAR=filename END=end ; /* NOTE use of FILEVAR & END */

INPUT ssn $; /* correct location for ssn needed here */ IF ssn = '015-43-9999' THEN DO; /* check for the ssn */ /* whatever you want to do */ STOP; /* stops processing data step */ END; END; run;

Hope this helps you and others out. +-------------------------------------------------------------------------+ | Kenneth A. Hardy | KEN_HARDY@UNC.EDU | | Assoc. Dir. for Information Systems | or | | Inst. for Research in Social Science | KHARDY@GIBBS.OIT.UNC.EDU | | University of North Carolina | | | Manning Hall CB#3355 | Voice: 919-966-4791 | | Chapel Hill, N.C. 27599-3355 | FAX: 919-962-IRSS | +-------------------------------------------------------------------------+

Back to: Top of message | Previous page | Main SAS-L page