* WARNING * The Government of Canada (Statistics Canada) is the owner of all intellectual * property rights (including copyright) in this software. Subject to the terms below, * you are granted a non-exclusive and non-transferable licence to use this software. * * This software is provided "as-is", and the owner makes no warranty, either express * or implied, including but not limited to, warranties of merchantability and fitness * for any particular purpose. In no event will the owner be liable for any indirect, * special, consequential or other similar damages. This agreement will terminate * automatically without notice to you if you fail to comply with any term of this * agreement.; /*******************************************************************/ /* Date: April 2004 */ /*******************************************************************/ /*********************************************************************************/ /*** ***/ /*** BOOTVARE_V30.SAS ***/ /*** ***/ /*** This program calculates variance estimates using the bootstrap weights ***/ /*** for different types of estimators. Using SAS macros, this program can ***/ /*** calculate variance estimates for totals, ratios and differences between ***/ /*** ratios. It can also calculate variance estimates for the parameters ***/ /*** of a regression or a logistic regression. This program can also be ***/ /*** customized for other types of analyses. ***/ /*** ***/ /*** The program is divided in 2 sections. Throughout the program, it is ***/ /*** indicated where the user has to make changes. ***/ /*** ***/ /*** Section 1: Declaration of the macro variables ***/ /*** This is where variables that are going to be used throughout ***/ /*** the program have to be defined. Some changes must be made ***/ /*** by the user. This is also where the files containing the ***/ /*** variables to analyze and the bootstrap weights are read in. ***/ /*** ***/ /*** Section 2: Declaration of the macros ***/ /*** This is where the user indicates what analysis they wish to ***/ /*** perform. Given the large number of observations to analyze, ***/ /*** it is recommended that the number of analyses be limited, ***/ /*** especially in the case of regressions. ***/ /*** ***/ /*** This program calls the program MACROE_V30.SAS. MACROE_V30.SAS contains ***/ /*** different macros that enable variance estimation. For standard use of the***/ /*** variance estimation program, no modification by the user to MACROE_V30.SAS***/ /*** is necessary. Changes may be required in certain cases explained in ***/ /*** section 2 of the program. ***/ /*** ***/ /*** ***/ /*** Before using the program BOOTVARE_V30.SAS, the user has to prepare ***/ /*** an analysis file that contains the variables to analyze. ***/ /*** ***/ /*** To calculate a total, ratio or difference between ratios, the ***/ /*** estimates are obtained by summing the weights of the records that have ***/ /*** the characteristic of interest. Therefore, a dummy variable must be ***/ /*** created for each of the variables to be analyzed. This variable takes a ***/ /*** value of 1 when the record has the characteristic and 0 otherwise. ***/ /*** ***/ /*** NOTE: This file should only contain the records necessary for the ***/ /*** analysis (ex: if the analysis is performed on the age group 12 and over, ***/ /*** only the records for individuals 12 and over should be included in ***/ /*** the file.) ***/ /*********************************************************************************/ /*****************************************************************************/ /*** SECTION 1 ***/ /*****************************************************************************/ /*** ***/ /*** This section lets the user specify the different parameters of ***/ /*** interest (variable names, directory names, file names, etc.) ***/ /*** ***/ /*****************************************************************************/ ************************************************************************* ** SPECIFY THE NAME OF THE FOLLOWING 2 DIRECTORIES (directories only): ** *************************************************************************; libname in1 "name_of_the_directory_containing_analysis_file_(step 1)"; /* (ex: c:\data) */ libname out "name_of_the_directory_to_save_results_in"; /* (ex: c:\output)*/ ************************************************************************************* ** SPECIFY THE NAME OF THE ANALYSIS FILE (CREATED IN STEP 1) (without extension): ** *************************************************************************************; %let Mfile = in1.Name_of_analysis_file; ************************************************************************* ** SPECIFY THE NAME OF THE FILE CONTAINING THE BOOTSTRAP WEIGHTS: ** ** NB: Only run one of the two following series of commands ** ** (comment the other one out, or erase it): ** *************************************************************************; * EXECUTE THIS PART IF THE BOOTSTRAP WEIGHTS ARE IN SAS FORMAT (remove the " * ") -------------------------------------------------------------------------------; * libname in2 "directory_name_containing_bootstrap_weights_file"; /* (ex: c:\bootstrp)*/ * %let bsamp=in2.SAS_file_name_containing_the_weights_(without extension) ; * EXECUTE THIS PART IF THE BOOTSTRAP WEIGHTS ARE IN ASCII (.TXT) FORMAT (remove the " * ") ----------------------------------------------------------------------------------------; * data bootwt; * %let datafid="(directory)location_and_bootstrap_weights_file_(with_extension) "; * %include "(directory)location_and_file_name_of_layout_(with_extension)"; * run; * %let bsamp=bootwt; ********************************************************************************************* ** SPECIFY, IF DESIRED, THE BREAKDOWN VARIABLE(S) (EG: PROVINCE, SEX, ETC...): ** ** Write the name of the breakdown variable(s) below. ** ** ** ** - If the analysis includes all of the data in the file created in step 1, put ** ** a dot. (%let classes =. ) ** ** - If more than one variable, leave a blank between each variable ** ** (%let classes=var1 var2) ** ** - DO NOT ERASE OR COMMENT OUT THIS COMMAND ** *********************************************************************************************; %let classes = breakdown_variable(s)_or_a_dot ; ********************************************************************************************* ** SPECIFY THE FOLLOWING INFORMATION (SPECIFIC TO THE SURVEY YOU ARE USING): ** ** You must specify: ** ** 1- The unique identifier variable(s) (separated by a space) ** ** 2- The Final Weight (variable included in the bootstrap weight file) ** ** 3- The prefix of the boostraps weight variables ** ** 4- The number of bootstrap weights to use (note: For testing, B must be >= 2. ** ** IT IS NECESSARY TO USE ALL THE BOOTSTRAP WEIGHTS WHEN PERFORMING THE FINAL ** ** ANALYSIS. THE COMPLETE BOOTVARE_V30.SAS PROGRAM MUST THEN BE RUN.) ** ** ** ** - Refer to AppendixC_XYZ to obtain this information ** *********************************************************************************************; %let ident = unique identifier variable(s); %let fwgt = final_weighf; %let bsw = prefix_of_bootstrap_weight_variables; %let B = number_of_weights_to_use ; ********************************************************************************* ** SPECIFY THE DIRECTORY AND THE NAME OF THE FILE THAT CONTAINS THE MACROS ** ** (THE PROGRAM MACROE_V30.SAS IF NO MODIFICATIONS HAVE BEEN MADE BY THE USER) ** *********************************************************************************; %include "directory_name_of_macroe_v30.sas\MACROE_V30.SAS"; /*****************************************************************************/ /*** SECTION 2 ***/ /*****************************************************************************/ /*** ***/ /*** This section lets the user specify the different analyses of interest.***/ /*** ***/ /*****************************************************************************/ /***********************************************************************************/ /*** Variance estimates are calculated using the SAS macros defined in the ***/ /*** MACROE_V30.SAS program. These SAS macros can be submitted in this program, ***/ /*** to suit the user's needs. ***/ /*** ***/ /*** To submit a macro, the statement must specify the macro name and parameters ***/ /*** to use. In this program, the parameters indicate which variables will be ***/ /*** used. ***/ /*** ***/ /*** Each macro submission gives an estimate of the variance of only one ***/ /*** parameter. If more than one parameter and variance need to be ***/ /*** calculated, the macro then must be submitted several times. ***/ /*** ***/ /*** A statement for each possible type of analysis appears in the program. They ***/ /*** are commented out and the user only needs to run those that are desired. ***/ /*** ***/ /*** ***/ /*** COMMENT ABOUT DIFFERENCES BETWEEN RATIOS: ***/ /*** ---------------------------------------- ***/ /*** ***/ /*** The confidence interval is calculated for a single comparison of ratios. If***/ /*** multiple comparisons are made, the method used to calculate the confidence ***/ /*** interval must take this into account. For this reason, in the case of ***/ /*** multiple comparisons, the Z value from the normal distribution used in the ***/ /*** calculation of the confidence interval must be corrected in the diff_rat ***/ /*** macro in the MACROE_V30.SAS program using, for example, the Bonferroni ***/ /*** approach for multiple comparisons. ***/ /*** ***/ /***********************************************************************************/ * TO OBTAIN VARIANCE ESTIMATES OF A TOTAL, RUN: ---------------------------------------------; * %total(variable_name); * TO OBTAIN VARIANCE ESTIMATES OF A RATIO, RUN: ---------------------------------------------; * %ratio (numerator_variable, denominator_variable); * TO OBTAIN VARIANCE ESTIMATES OF A DIFFERENCE BETWEEN RATIOS, RUN: -----------------------------------------------------------------; *NOTE: see the comment at the beginning of section 2 ... ; * %diff_rat(VAR1,VAR2,VAR3,VAR4); * where: var1 : the numerator variable of the first ratio * * var2 : the denominator variable of the first ratio * * var3 : the numerator variable of the second ratio * * var4 : the denominator variable of the second ratio *; * TO OBTAIN VARIANCE ESTIMATES OF REGRESSION PARAMETERS, RUN: -----------------------------------------------------------; * %regress(dependent_variable, independent_variables_(no comma)) ; * TO OBTAIN VARIANCE ESTIMATES OF LOGISTIC REGRESSION PARAMETERS, RUN: --------------------------------------------------------------------; * %logreg(dependent_variable, independent_variables_(no comma)); %output; /*Displays the results on the screen. Do not modify. */ * TO SAVE THE RESULTS IN A FILE, RUN: (remove the "*") ----------------------------------------------------; * data out.Results_filename ; * set &result ; * run; /* end of BOOTVARE_V30.SAS program */