> I wanted to walk through this, I am commenting it so
> maybe you can direct me in the things I do not
> understand.
>
>
This first data step creates "example" files. My attempt was to make a working example. If you submit this from a DM session it should create .\xUsers.... directories under the "current" directory. Then it just write a few files that the next step can read. You already have these so understanding how this work is not important at this time.
> dm 'clear log; clear output;';
> * create test data(files to be read in next step);
> data _null_;
> length command $256; *command will be the location
> n of the files;
> infile cards truncover; *tells SAS to read through
> h the cards later in the program;
> input name :$128.; *what it reads in will be called
> d 'name' What does the ':' do?
> if _n_ eq 1 then do;
> path =
> = quote(substr(name,1,find(name,'\',-length(name))));
> *define the path name;
> command = 'rmdir /S /Q ".\xUsers\"'; *don't
> t understand this step;
> infile dummy1 pipe filevar=command; *read all of
> of the files located in the command location (or open
> a pipe to that location);
> command=catx(' ','mkdir',path); *creates this
> is directory with the location designated in path;
> put command=;
> infile dummy1 pipe filevar=command; *pipe again to
> to command location. What exactly does filevar=
> do?;
> rc = sleep(1);
> end;
> file dummy filevar=name dsd dlm=',';
> do _n_ = 1 to 6;
> put _n_:z5. name;
> end;
> cards; *read the cards. How do I get ALL the files
> s I need here?;
> .\xUsers\mherrin\Documents\trial\APX05132005.1
> .\xUsers\mherrin\Documents\trial\APX05132005.2
> .\xUsers\mherrin\Documents\trial\APX0513.DRF
> .\xUsers\mherrin\Documents\trial\APX05142005.1
> .\xUsers\mherrin\Documents\trial\APX05142005.2
> .\xUsers\mherrin\Documents\trial\APX0514.DRF
> ;;;;
> run;
>
This next step is something somewhat like what I think you will end up writing. I reads all files NAME from "a directory tree" that is specific to YOU, using DIR /S/B "path".
This particular step looks for files with file type .1 when they are found it reads the files. This example just reads two fields that were written in the first step. Your actualy program will have a "much" long input statement.
> *Read Type .1 (RACE) files;
>
> data type1;
> length command filename fname path $256.;
> command = 'dir /s /b ".\xUsers"'; *dir has not been
> n defined how does this work?;
> infile dummy1 pipe filevar=command truncover;
> input path $256.;
> if scan(path,-1,'.') eq '1'; *selects only the .1
> 1 files;
> put _infile_; *???;
> infile dummy2 filevar=path filename=fname end=eof
> f dsd;
> filename = scan(fname,-2,'.\'); *fname does not
> t exist in this data set at the end?;
> length prefix $3.;
> prefix = filename; *assumes prefix is always first 3
> 3 characters;
> date = input
> t (substr(filename,anydigit(filename)),mmddyy10.);
> do while(not eof);
> input obs name:$64.; ** Fields for type 1 files?;
> output;
> end;
> format date date9.;
> run;
>
>
>
> In the end I get a data file with the variables you
> defined; filename, prefix, date, ... I know you
> wrote above to put in the field types for the data do
> I need to first declare them in the lenght statement
> above? It does not seem to be reading any
> information from the file itself only the file name
> so far.
>
> Thanks.
... View more