Search code examples
perlsasfile-conversionperlscript

Convert file with XPT extension to Excel using Perl


I am currently new to Perl Scripting a detailed explanation would be helpful. I tried using the SAS Parser module but i guess it is for .sas files only. Please suggest which library to use for this task.


Solution

  • You can pass from xlsx to xpt with SAS easily following this example :

    From XLSX to the XPT format :

    options VALIDVARNAME=V6;
    libname in xlsx "H:\desktop\XLSX\d.xlsx";
    libname out xport "H:\desktop\test.xpt";
    proc copy inlib=in outlib=out;
    run;
    libname in clear;
    libname out clear;
    

    From XPT to the XLSX format :

    options VALIDVARNAME=V6;
    libname out xlsx "H:\desktop\XLSX\d2.xlsx";
    libname in xport "H:\desktop\test.xpt";
    proc copy inlib=in outlib=out;
    run;
    libname in clear;
    libname out clear;
    

    It worked on my computer. Be careful because it truncate the column (due to the option VALIDVARNAME=V6).