Search code examples
sassas-ods

SAS print text from file to spreadsheet


Is there a way to print the contents of a .txt file to a tab using ods tagsets.excelxp? I have a script that creates a .xml file with several tabs, and on one of the tabs I'd like to print the lines of the code itself, so that I can send the .xml file to someone and they can have the code that I used to produce the output. I have the code saved separately as a .txt. Any help or suggestions would be appreciated.


Solution

  • Easiest way would be to read the text file lines into a Data Set. Then use PROC PRINT to print to your output destination;

    data lines;
    infile "path/to/file.txt";
    format code $2000.;
    input;
    code = _infile_;
    run;
    
    proc print data=lines noobs;
    run;