LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (January 2007, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 23 Jan 2007 07:35:23 -0500
Reply-To:     Nathaniel_Wooding@DOM.COM
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Nat Wooding <Nathaniel_Wooding@DOM.COM>
Subject:      Re: Reading Multiple Raw Files ..
Comments: To: Kumar <ravi_pune@YAHOO.COM>
In-Reply-To:  <374292.49529.qm@web30105.mail.mud.yahoo.com>
Content-Type: text/plain; charset="US-ASCII"

Kumar

Here's a bit of code which reads a series of files and writes them out appending the filename.

data a;

filename txt 'u:\PERSONAL\*.sas'; length file $ 50; infile txt filename=file lrecl=80 truncover; informat txt $72.; input txt $ 1-72;;

source=file;

source=scan(source,-2 );* you will need to edit this statement in order to extract the bits that you need.

It is necessary to assign the value from the filename variable to another variable.

Nat Wooding

Kumar <ravi_pune@YAHOO. COM> To Sent by: "SAS(r) SAS-L@LISTSERV.UGA.EDU Discussion" cc <SAS-L@LISTSERV.U GA.EDU> Subject Reading Multiple Raw Files ..

01/23/2007 04:55 AM

Please respond to Kumar <ravi_pune@YAHOO. COM>

Assuming that I have something like this ...

filename in ('c:\Test.log', 'c:\Test2.log');

data output; infile in length=len; input record $varying1000. len; run;

Is there anyway I can get to know the source of each observation in dataset output? In othe words, I want the dataset 'output' to have another column (say 'sourcefile') that has either the value 'Test.log' or 'Test2.log' based on which raw file that particular observation was read from.

Is there an easy way to do this?

Thanks Ravi

__________________________________________________________ Yahoo! India Answers: Share what you know. Learn something new http://in.answers.yahoo.com/

----------------------------------------- CONFIDENTIALITY NOTICE: This electronic message contains information which may be legally confidential and/or privileged and does not in any case represent a firm ENERGY COMMODITY bid or offer relating thereto which binds the sender without an additional express written confirmation to that effect. The information is intended solely for the individual or entity named above and access by anyone else is unauthorized. If you are not the intended recipient, any disclosure, copying, distribution, or use of the contents of this information is prohibited and may be unlawful. If you have received this electronic transmission in error, please reply immediately to the sender that you have received the message in error, and delete it. Thank you.


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