/******************************************************************************/
/*                                                                            */
/*         SAS Program to Convert SAS Export Files to SAS Data Files          */
/*                           PIRLS 2016 User Guide                            */
/*                                                                            */
/******************************************************************************/

OPTIONS NONOTES MPRINT ;

%MACRO DOIT (TYPE   = ,
             INDIR  = ,
             OUTDIR = ) ;

  LIBNAME OUTDIR "&OUTDIR" ;

  * Start of file type processing loop ;

  %DO F = 1 %TO %SYSFUNC(COUNTW(&TYPE)) ;
    %LET FTYPE = %SCAN(&TYPE,&F) ;

    * List of ePIRLS 2016 countries ;

    %LET COUNTRY = CAN TWN DNK GEO IRL ISR ITA NOR PRT SGP
                   SVN SWE ARE USA
                   AAD ADU ;

  * Start of country processing loop ;

    %DO I = 1 %TO %SYSFUNC(COUNTW(&COUNTRY)) ;
      %LET CTRY = %SCAN(&COUNTRY,&I) ;

      PROC CIMPORT FILE="&INDIR\&FTYPE&CTRY.E1.EXP"
                   DATA=OUTDIR.&FTYPE&CTRY.E1 ;
      RUN ;

      * End of country processing loop ;

    %END ;

    * End of file type processing loop ;

  %END ;

%MEND DOIT ;

%DOIT (TYPE   = ACG ASA ASG ASH ASR AST ATG ,
       INDIR  = <specify location of SAS export files using format "x:\xxx"> ,
       OUTDIR = <specify location of SAS data files using format "x:\xxx"> ) ;
