Search code examples
sqlsassas-macro

Importing .sas into SAS as text


Is there a way to import the actual code of a .sas file into SAS without changing the base file to a .txt. I’m trying to make a tool to search through lines of code for certain keywords.


Solution

  • You can use infile statement:

    filename sastext "\test.sas";
    
    data sastext;
       infile sastext truncover;
       input str $32000.;
    run;
    
    filename sastext clear;
    

    test.sas:

    data _null_;
       put "TEST";
    run;
    

    dataset sastext:

    +-----------------+
    |       str       |
    +-----------------+
    | data _null_;    |
    | put "TEST";     |
    | run;            |
    +-----------------+