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 (February 2002, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 20 Feb 2002 13:08:52 +0100
Reply-To:     Peter Crawford <peter.crawford@DB.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Peter Crawford <peter.crawford@DB.COM>
Subject:      Re: Automate Files Import by using SAS statement
Comments: To: siapaini <siapaini@INAME.COM>
Content-type: text/plain; charset=iso-8859-1

Assuming these are data files, one sas datastep might complete the process. Prerequisites are simply that there is some way you can recognise what to do with these data files from their names or from the content of each data line

data table1 table2 table3 ....... tableN; /* it is this simple to define more than one output sas dataset in one data step */ length fileName fileNam $200 thisFile $66; infile "!temp\*.*" /* address all files in temp folder with std windows environment variable */ filename = filenam /* current path\name of each file*/ lrecl = 50000 /* allow large input buffers */ truncover /* allow last column to be short */ /* DSD DLM='<your choice>' /* your preferred handling */ length = len /*like to know current line length*/ column = col /* and input position in line */ ; input @ ; /* collect infile buffer from first file */ thisFile = scan( fileNam, -1, '\' ); /* removing path*/ if <conditions based on filename, test variable "thisFile" > <conditions on input record, test variable "_infile_" > then do; %include "process to handle this type of data" ; end; else if <more conditions > then do; %include "process to handle this type of data" ; end; else .............. run;

Each process is responsible for input statements or parsing _infile_ and outputing to appropriate datasets. If different variables are wanted on each output dataset, these should be defined in the DATA statement as dataset option(keep= ), like data table1(keep=<table1 var list> ) table2(keep=<list of vars in table2>) ....... tableN(keep=<list of vars in tableN>) ;

I hope this provides some structure for the weak definition in the request from siapaini <siapaini@INAME.COM>

Regards Peter Crawford

Datum: 20/02/2002 09:21 An: SAS-L@LISTSERV.UGA.EDU

Antwort an: siapaini <siapaini@INAME.COM>

Betreff: Automate Files Import by using SAS statement Nachrichtentext:


Wonder if anyone can help me in how can i automate the import of files (text files) by using macro in windows environment. Says if I have 20-30 text files stored in d:\temp\ and there is no standard filename naming convention for all these files. Wonder if I can scan the whole folder and read in all the text files by using SAS statement ?


Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet.

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.

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