[CinSUG] Addendum to presentation

  • From: "Jeff Ahrnsen" <jeff.ahrnsen@xxxxxxxxx>
  • To: cinsug@xxxxxxxxxxxxx
  • Date: Thu, 20 Apr 2006 10:57:04 -0400

Just a quick addendum,

Below you find code similar to what Jon provided in his presentation that
reads in a group of similar files within a directory, regardless of the name
of the file. Thanks to Wensui Liu to providing this!  For more code by
Wensui, visit his blog at http://statcompute.blogspot.com

Regards,
Jeff

*************************************************
* READ ALL FILES IN A FOLDER INTO SAS *
* USING OPERATING SYSTEM PIPE *
* DATE: 28-SEP, 2005 *
*************************************************;

/*
SAMPLE DATA IN 4 FILES WITH UNKNOWN NAMES
12011997 M 09/08/04
12011997 F 01/26/01
...
*/

/* USE PIPE TO RETURN A LIST OF FILENAMES */
filename indata pipe 'dir "C:\temp" /b';

data File Data;
format path $100.;
/* OPEN A PIPE FOR INPUT */
infile indata truncover;
/* INPUT FILE NAMES */
input file $20.;
/* SPECIFY FULL PATH OF FILES */
path = 'C:\temp\'||file;
put path;

/* OPEN EACH FILE */
infile dummy filevar = path end = done truncover;
do while(not done);
/* INPUT DATA IN THE FILE */
input Account $ 1-8 Sex $ 10-10 Date mmddyy8.;
format Date Date.;
output;
end;
run;

*************************************************
* END OF CODE *
*************************************************;

Other related posts:

  • » [CinSUG] Addendum to presentation