/******************************************************************************/
/*                                                                            */
/*         SAS Program to Convert SAS Export Files to SAS Data Files          */
/*                         Specific for 1995 Database                         */
/*                       TIMSS Advanced 2008 User Guide                       */
/*                                                                            */
/******************************************************************************/

OPTIONS NONOTES ;

* Specify the file type ;
* <type> must be edited ;
* MCG/PCG - MSA/PSA - MSG/PSG - MSR/PSR ;

%LET TYPE = <type> ;

* Specify the path for the sas export files following the format x:\xxx\ ;
* <exppath> must be edited ;

%LET EXPPATH = <exppath> ;

* Specify the path for the SAS data files following the format x:\xxx\ ;
* <datpath> must be edited ;

%LET DATPATH = <datpath> ;

%MACRO DOIT ;

   * Specify the list of countries to be processed ;

   %IF %UPCASE(%SUBSTR(&TYPE,1,1)) = M %THEN %DO ; * 4th grade countries ;

      %LET COUNTRY = AUS AUT CAN CYP CZE FRA DEU DNK GRC ISR
                     ITA LTU RUS SVN SWE CHE USA ;

   %END ;

   %IF %UPCASE(%SUBSTR(&TYPE,1,1)) = P %THEN %DO ; * 8th grade countries ;

      %LET COUNTRY = AUS AUT CAN CYP CZE FRA DEU DNK GRC ISR
                     LVA NOR RUS SVN SWE CHE USA ;

   %END ;

   %LET I = 1 ;
   %DO %WHILE(%LENGTH(%SCAN(&COUNTRY,&I))) ;
      %LET CTRY = %SCAN(&COUNTRY,&i) ;

      PROC CIMPORT FILE="&EXPPATH&TYPE&CTRY.M1.EXP"
                   DATA="&DATPATH&TYPE&CTRY.M1" ;
      RUN;

      %LET I = %EVAL(&I + 1) ;
   %END ;

%MEND DOIT ;

%DOIT ;
