Samples SAS     SAS to SQL
Concepts    Solutions    top  bottom

Sample processing multiple files

archive


References Situation, Concepts

Excel CSV TXT

Excel has possible many sheets. Processing sheets as tables is more sense using the libname statement to Excel.
SAS LIBNAME Statement Syntax for PC Files SAS/ACCESS(R) 9.4 Interface to PC Files: Reference, Second Edition

Using PC-files server can be an other component added to that.
When the presentation of the sheet is just a CSV or TXT file is easier to process.

SAS execute Code call

Having a list of files it is possible to execute genrated SAS-code.

SAS functions dir-listing

Having a list of files it is possible to execute genrated SAS-code.



Concepts    Solutions    top  bottom

Solution -SAS Code

Functional analyses

reading with wildcards assumes:

Explanation wildcards filename



Explanation file generating

reading with wildcards assumes:

SAS Code, reading file generating

filename tjaka "E:/sastest" ;
data work.filelst (keep=filenm) ;
    length filenmc filenm $255 ;
    infile tjaka(*.txt) filename=filenmc end=flend eov=frstrcr lrecl=32767 recfm=F truncover;
    input @1 var1 $1 ;
    if (frstrcr) then do; /* first record/data non empty file */
        filenm=filenmc;
        output work.filelst;
        ....
        call execute(....)
        ....
    end;
run;



Explanation libname to excel

reading Excel sheetnames: , original from Nat Wooding on SAS-L

SAS Code, reading tables in Excel

Libname in 'C:\Park\bhupindertest.xlsx';

Proc contents data = in._all_ out = a noprint; run;

Data _null_ ;
set a (keep = memname) end = eof;
    name = compress(memname, '$');
    name = translate(trim(name) , '_', ' ');
    str =compbl( "Data " || name || "; set in.'" || memname ||"'n;" );
    Call Execute (str);
    if eof then do;
       str = 'run;'; call execute (str);
    end;
run;



Concepts    Solutions    top  bottom
Samples SAS     SAS to SQL

© 2012 J.A.Karman