Software: IVEware: Imputation and Variance Estimation Software: IVEware Version 0.3 Documentation: IVEware User Guide

Chapter 1: Basics

1.1 What is IVEware?

IVEware is a collection of routines written under various platforms and packaged to perform multiple imputations, variance estimation and, in general, draw inferences from incomplete data. The software can also be used to perform analysis without any missing data. IVEware defaults to assuming a simple random sample, but uses the Jackknife Repeated Replication or Taylor Series Linearization techniques for analyzing data from complex surveys.

IVEware can be run with SAS, Stata, R, SPSS or as stand-alone under the Windows or Linux environment. The R, Stata, SPSS and stand-alone version can also be used with the Mac OS. The stand-alone version has limited capabilities for analyzing the multiply imputed data though the routines for creating imputations are the same across all packages. The command structure is the same across all platforms. IVEware can be executed using the built-in XML editor or it can be run using the built-in editor within the four software packages previously mentioned. The user can also mix and match the codes from these software packages through a standard XML toggle-parser (for example, < SAS name = "myfile" > SAS commands < /SAS >).

Back to top

1.2 Download and Setup

Various versions of IVEware can be downloaded and installed from IVEware Downloads. Installation instructions and setup are slightly different for Windows, Linux and MAC operating systems, therefore, it is very important to follow the instructions for IVEware to work properly.

Back to top

1.2.1 Windows

Download the file srclib_windows.exe and double click on it to install. By default, all the relevant software files are extracted to the directory

C:\Program Files (x86)\srclib

You may change the directory and the location you choose will then replace

~/srclib

in the guides given later to make IVEware work with one or more packages SAS, SPSS, Stata, and R. The installer will create a desktop icon unless you choose not to.

The next step is make sure that IVEware can execute the appropriate software. Find the path of the directory where the executable file of the software is located. For example, the typical location of the file “sas.exe” to run SAS version 9.4 is,

C:\Program Files\SASHome2\SASFoundation\9.4\sas.exe

Similarly, a 64-bit executable “Rgui.exe” may be located in

C:\Program Files\R\R-3.2.3\bin\x64\Rgui.exe

Find the path of the other software executable files, if needed.

Next edit the file “settings.xml” in the “srclib” directory. Here is an example of a file appropriate to run IVEware with all four software (SAS, R, Stata, and SPSS) packages:

<settings>
<frameworks>
<sas path="C:\Program Files\SASHome2\SASFoundation\9.4\sas.exe" />
<spss path="C:\Program Files\IBM\SPSS\Statistics\22\stats.exe" />
<stata path="M:\stata14SE-64bit\StataSE-64.exe" />
<R path="C:\Program Files\R\R-3.2.3\bin\x65\Rgui.exe" />
<gnuplot path="C:\Program Files\gnuplot\bin\wgnuplot.exe" />
</frameworks>
</settings>

In this example, the Stata executable file is located in the network drive M:. The standalone version uses “GNUPLOT” for creating and displaying graphics. You should download and install this package. For more details about this software, see www.gnuplot.info.

To verify that IVEware is correctly installed, download the example file:

ive_examples_windows.zip

and extract it to the directory of your choice (for example, create a subdirectory called iveware under the Documents directory). Double click the IVEware icon which will open an XML editor window. Choose “File”, navigate to the directory with the example files, choose any example XML file to open, and click “Run”. You can also run IVEware in batch mode by typing:

"C:\Program Files (x86)\srclib\srcexec" ive_example_file.xml

in the command window after setting the current directory to the directory where the example file is located. Use MS Word or another software to check the “*.log” files produced by the run to see that there were no errors and also compare the “*.lst” files produced by run with the corresponding “*.chk” files. They should differ only in the dates.

Back to top

1.2.2 Linux

For installing IVEware on a Linux system, download the file “srclib pclinux64.tgz” from IVEware Downloads and extract the srclib directory into an appropriate parent directory, such as, “/usr/local/” or in your home directory. You can copy the files into the subdirectory of your choice. The location you choose will replace “~/srclib” in guides for using IVEware with R, SAS, SPSS, Stata and Srcware, as described in later examples. If you plan to use Srclib with R, SAS, SPSS or Stata and the version cannot be invoked by its lower-case name, edit the “srclib/settings.xml” file to provide the correct path.

As before, you can verify that IVEware is installed correctly by downloading the file
ive_examples_pclinux.tgz” and extracting the examples directory into an appropriate parent directory, for example, the home directory. Navigate to the srclib directory, double-click the srcshell icon, click File-Open, navigate to the Examples directory, open an appropriate setup file, for example, “ive_examples_srcware.xml”, and finally, click Run. You can also run the program in batch mode. For example, navigate to the examples directory and use srcexec to run an appropriate setup file:

~/srclib/bin/srcexec ive_examples_sas.xml

where ~/srclib is the directory containing IVEware.

Use the Linux “cat” and “diff” commands (or other software such as OpenOffice), check the *.log files produced by the run to see that there were no errors and compare the *.lst files produced by run with the corresponding *.chk files. Again, they should differ only in the dates.

Back to top

1.2.3 MAC OS

For those using a MAC-OS, IVEware can be used only as stand-alone or with Stata, R and SPSS. For installing IVEware on a Mac OS system, download the file srclib macosx64.tgz from IVEware Downloads and extract the srclib directory into an appropriate parent directory, such as, “/usr/local/” or in your home directory. You can extract the files into a directory of your choice. The location you choose will replace “? /srclib” in guides for using IVEware with R, SAS, SPSS, Stata and Srcware, as described in later examples. If you plan to use Srclib with R, SAS, SPSS or Stata and the version cannot be invoked by its lower-case name, edit the “srclib/settings.xml” file to provide the correct path.

As before, you can verify that IVEware is installed correctly by downloading the file “ive examples macosx.tgz” and extracting the examples directory into an appropriate parent directory, for example, the home directory. Navigate to the srclib directory, double-click the srcshell icon, click File-Open, navigate to the Examples directory, open an appropriate setup file, for example, “ive_examples_srcware.xml“, and, finally, click Run. You can also run the program in batch mode. For example, navigate to the examples directory and use srcexec to run an appropriate setup file, for example:

~/srclib/bin/srcexec ive\_examples\_sas.xml

where “~/srclib” is the directory containing IVEware.

Use the MacOS/Linux “cat” and “diff” commands (or other software, such as OpenOffice) to check the “*.log” files produced by the run to see that there were no errors and to compare the “*.lst” files produced by the run with the corresponding “*.chk” files. They should differ only in the dates.

Back to top

1.3 Structure of IVEware

IVEware is organized into seven modules to perform various tasks. The six core modules are IMPUTE, BBDESIGN, DESCRIBE, REGRESS, SYNTHESIZE and COMBINE and the seventh module, SASMOD, is specific to SAS.

  1. IMPUTE uses a multivariate sequential regression approach (Raghunathan et al. (2001), Raghunathan (2015)). This approach is also called Chained Equations, (Van Buuren and Oudshoorn (1999)) and Fully Conditional Specification (Van Buuren (2012)) and is used to impute item missing values or unit non-response. IMPUTE can create multiply imputed data sets and can handle continuous, categorical, count and semicontinuous variables.
  2. BBDESIGN implements the weighted finite population Bayesian Bootstrap approach to generate synthetic populations from complex survey data. The primary goal is to incorporate weighting, clustering and stratification in a nonparametric approach for generating the non-sampled portion of the population from the posterior predictive distribution, conditional on the observed data and the design information. For more details see Zhou, Elliott and Raghunathan (2015, 2016a, 2016b)
  3. BBDESIGN implements the weighted finite population Bayesian Bootstrap approach to generate synthetic populations from complex survey data. The primary goal is to incorporate weighting, clustering and stratification in a nonparametric approach for generating the non-sampled portion of the population from the posterior predictive distribution, conditional on the observed data and the design information. For more details see Zhou, Elliott and Raghunathan (2015, 2016a, 2016b)
  4. REGRESS fits linear, logistic, polytomous, Poisson, Tobit and proportional hazard regression models. For data resulting from a complex sample design, the Jackknife Repeated Replication technique is used to obtain variance estimates. As in other IVEware commands, a multiple imputation analysis can be performed when there are missing values.
  5. SYNTHESIZE uses the multivariate sequential regression approach to create full or partial synthetic data sets to limit statistical disclosure (See Raghunathan, Reiter and Rubin (2003), Reiter (2002), and Little, Liu and Raghunathan (2004) for more details.) All item missing values are also imputed when creating synthetic data sets. However, DESCRIBE, REGRESS and SASMOD modules cannot be used to analyze synthetic data sets as they DO NOT implement the appropriate combining rules. Examples of implementation of correct combining rules for synthesized data sets are included in later sections of this guide.
  6. COMBINE is useful for combining information from multiple sources through multiple imputation. Suppose that Data 1 provides variables X and Y, Data 2 provides variables X and Z and Data 3 provides variables Y and Z. COMBINE can be used to concatenate the three data sets and multiply impute the missing values of X, Y and Z to create large data sets with complete data on all three variables. All item missing values in the individual data sets will also be imputed. The multiply imputed combined data sets can be analyzed using DESCRIBE, REGRESS and SASMOD modules (see Schenker, Raghunathan, and Bondarenko (2010) for an application and Dong, Elliott and Raghunathan (2014a, 2014b) for more details).
  7. SASMOD (requires SAS) allows users to take into account complex sample design features when analyzing data with selected SAS procedures. Currently the following SAS PROCS can be called: CALIS, CATMOD, GENMOD, LIFEREG, MIXED, NLIN, PHREG, and PROBIT. A multiple imputation analysis can be performed when there are missing values. Unlike the other IVEware modules, SASMOD requires SAS.

There are many packages such as R (“with”, “mitools”, and “pool”), Stata (“mi estimate”), SAS (”PROC MI, PROC MIANALYZE”) to analyze multiply imputed data sets. All these packages can be used within the “XML” structure of IVEware.

Back to top

1.4 How to run IVEware with software packages?

There are many ways to run IVEware. The choice of how to run the program may depend upon whether the data is stored as a text file or as a software specific file (such as a SAS data set) or whether to use the Srcshell XML editor bundled with IVEware or use the built-in editors in specific software package (such as program editor in SAS). IVEware can also be run in batch mode using the command file. Given this level of flexibility, it is not possible to cover every method in detail. Nevertheless, the next few sections provide various example scenarios which might help users develop code for their own needs and situation. Additional examples of running IVEware are provided in later chapters.

This section uses the data from a case control study that was conducted in Seattle and King County to assess the relationship between dietary intake of omega-3 fatty acids (in particular, docosahexaenoic and eicosapentaenoic acids). These fatty acids are mostly derived from eating fish or seafood. Table 1.1 provides a list of variables and a description of the content. The goal of this example is to perform multiple imputation of the missing values.

Table 1.1: A list of variable in the data set used in the example
Variable Description Remarks
CASECNT Case-Control Status 1=Case; 0=Control
AGE Age at time of event (case) or interview (control) Continuous
GENDER Gender of subject 1=Female; 0=Male
RACE3 Race of the subject 1-White; 0=Non-white
HYPER Hypertension status 1=Hypertensive; 0=Not Hypertensive
DIAB Diabetes Status 1=Diabetic; 0=Non-diabetic
SMOKE Smoking Status 1=Never; 2=Former; 3=Current
NUMCIG Number of Cigarettes per week Continuous, restricted to current and former smokers
TRSSMOKE Number of years smoked Continuous, restricted to current and former smokers, must be less than age
FATINDEX Score measuring total Fat intake Continuous
FAMMI History of Family history 1=Yes; 0=No
EDUSUBJ3 Education Categories Less than High school; High school; some College and College
DHA_EPA Dietary inake of Omega-3 based on Food Frequency Questionnaire Continuous
REDTOT Red cell membrane measure of Omega-3 Continuous
CHOLESTH High cholesterol 1=Yes; 0=No
CAFFTOT Caffeine intake Semi-continuous or Mixed
WGTKG Weight in Kilograms Continuous
TOTLKCAL Total Kcal spent on physical activity Continuous
ALCOHOL3 Alcohol Intake Semi-continuous or Mixed
HGTCM Height in centimeters Continuous

Back to top

1.4.1 IVEware and SAS

As explained earlier, IVEware can be run using the provided XML editor or using the Regular Program Editor in SAS (NOT the Enhanced Editor). The XML editor approach is described first as it is our most preferred approach. This analysis uses data stored in a text file (“mydata2.txt”) with the first row representing the variable names. Create and save an XML file (the default extension is “.xml”) with the following structure. The commands are explained whenever needed.

<sas name="ive_examples">

/* iveware examples - sas version */

/* import the input datasets */

proc import datafile=’mydata2.txt’ out=mydata2 dbms=tab replace;
getnames=yes;
run;

The first line

<sas name="ive_examples">

indicates the beginning of SAS commands which are to be stored in a file called “ive examples.sas” in the current directory (the same directory where the XML file will be stored). The files called ive examples.log and ive examples.lst are the corresponding log and list files created by SAS. The command,

<sas name="ive_examples",dir="c:\mydir">

will store the sas, log and list files in the directory “c:\mydir”.

Once the SAS toggle has been invoked, any SAS commands can be inserted including comments. Here, ”PROC IMPORT” is used to import a text file and create a data set called “mydata2.sas7bdat” in the SAS work directory. The user can provide a full path for these filenames and also use libname in SAS to point to the directory containing the data files.

/* run iveware */

/* multiple imputation */

<impute name="impute">
title Multiple imputation;
datain mydata2;
dataout impute;
default continuous;
categorical casecnt gender race3 hyper diab smoke fammi edusubj3 cholesth;
mixed cafftot alcohol3;
transfer studyid;
restrict numcig(smoke=2,3) yrssmoke(smoke=2,3);
bounds numcig(>0) yrssmoke(>0,<=age-12) fatindex(>0) cafftot(>=0) alcohol3(>=0);
maxpred redtot(3) wgtkg(2);
minrsqd .01;
iterations 5;
multiples 5;
seed 2001;
run;
</impute>

The command

<impute name="impute">

now toggles the beginning of the IMPUTE module and stores commands in a file called “impute.set” in the current directory (that is, directory where the XML file is stored). All IVEware files (produced by IMPUTE, DESCRIBE, REGRESS, COMBINE and SYNTHESIZE) have a “.set” extension. The filenames in “datain” and “dataout” can follow the SAS convention of “libname.sasname” while a libname can be assigned before invoking IMPUTE. For more detail on IMPUTE keywords, see Chapter 2. The line:

</impute>

indicates the closure or end of the IMPUTE commands. Finally, the

</sas>

command indicates the end of all SAS commands. Now, click “run” to execute the program. If you already have a setup file named “impute.set” in the directory, it will be overwritten.

Once you have run the Srcshell, you can reuse the SAS setup file it creates, “ive examples.sas” without Srcshell by issuing the following command

sas ive_examples.sas

in a command window to run in batch mode. Similarly, in the Linux system, you can use

sas ive_examples.sas &

to run the program in background. Suppose that you have a setup file called “previousrun.set” from a previous run then you can rerun it by creating a simpler xml file consisting of the single line:

<impute name="previous" />

and then click “run”.

IVEware can be run interactively in Windows SAS by using the Regular Program Editor (once again, NOT the Enhanced Editor). First, open or create and save a SAS program (.sas) file and then submit or run it as usual from the editor. This may be an attractive option, especially if you are used to running SAS and an earlier version of IVEware. For example, the first line in the SAS command file is the following options statement:

options set = SRCLIB ’~/srclib/sas’ sasautos=(’!SRCLIB’ sasautos) mautosource;

where

~\srclib

is the IVEware installation directory.

This approach (as opposed to the modification of the SAS configuration file used in the previous version of IVEware) is easier, especially, when the user does not have write privileges for the configuration file (such as with a network installation). The following commands can be used to perform the same set of tasks as in the XML version discussed above.

/* iveware examples - sas version */

/* import the input datasets */

proc import datafile=’mydata2.txt’ out=mydata2
dbms=tab replace;
getnames=yes;
run;

/* run iveware */

/* multiple imputation */

%impute(name=impute, dir=. setup=new);
title Multiple imputation;
datain mydata2;
dataout impute;
default continuous;
categorical casecnt gender race3 hyper diab smoke fammi
edusubj3 cholesth;
mixed cafftot alcohol3;
transfer studyid;
restrict numcig(smoke=2,3) yrssmoke(smoke=2,3);
bounds numcig(>0) yrssmoke(>0,<=age-12) fatindex(>0)
cafftot(>=0) alcohol3(>=0);
maxpred redtot(3) wgtkg(2);
minrsqd .01;
iterations 5;
multiples 5;
seed 2001;
run;

Click ”run” to submit the commands. You can modify the program and use the libname and other SAS features to read data from a different directory, store the output in another directory, and save and execute the program in some other directory.

Back to top

1.4.2 IVEware and R

The structure of running IVEware in the R-package is very similar to running in the SAS environment as described in the previous section. Using the Srcshell XML editor, you can create the following commands:

<R name="ive_examples">

# The above line toggles the beginning of the R commands

# iveware examples - R version

# import the input datasets

mydata2 <- read.delim("mydata2.txt")
save(mydata2, file="mydata2.rda")

# run iveware

# multiple imputation

<impute name="impute">
title Multiple imputation;
datain mydata2;
dataout impute;
default continuous;
categorical casecnt gender race3 hyper diab smoke fammi
edusubj3 cholesth;
mixed cafftot alcohol3;
transfer studyid;
restrict numcig(smoke=2,3) yrssmoke(smoke=2,3);
bounds numcig(>0) yrssmoke(>0,<=age-12) fatindex(>0)
cafftot(>=0) alcohol3(>=0);
maxpred redtot(3) wgtkg(2);
minrsqd .01;
iterations 5;
multiples 5;
seed 2001;
run;
</impute>

# The line below indicates the end of R-commands
</R>

Click “run” to execute the command. This will create a file called “ive examples.R” with R commands and the “impute.set” file with all needed Impute commands . If you already have the files with those names, then they will be overwritten.

Some users may prefer to run IVEware fully in the R environment instead of using the Srcshell XML editor. Use any text editor to create save an Impute setup file (say, “impute.set” or any other file with a “.set” extension) with the following structure. The command file along with the data file should either be in the same directory or you can simply provide the full path in the command file.

title Multiple imputation;
datain mydata2;
dataout impute;
default continuous;
categorical casecnt gender race3 hyper diab smoke fammi
edusubj3 cholesth;
mixed cafftot alcohol3;
transfer studyid;
restrict numcig(smoke=2,3) yrssmoke(smoke=2,3);
bounds numcig(>0) yrssmoke(>0,<=age-12) fatindex(>0)
cafftot(>=0) alcohol3(>=0);
maxpred redtot(3) wgtkg(2);
minrsqd .01;
iterations 5;
multiples 5;
seed 2001;
run;

Next Start R. In the R editor, type the R commands and execute as usual.

# iveware examples - R version

# import the input datasets

mydata2 <- read.delim("mydata2.txt")
save(mydata2, file="mydata2.rda")

# initialize srclib

srclib <<- "~/srclib/R"
source(file.path(srclib, "init.R", fsep=.Platform$file.sep))

# run iveware

# multiple imputation

impute(name="impute")

Use the full path of the actual directory where IVEware is installed for

~/srclib

Back to top

1.4.3 SPSS and IVEware

Running IVEware with SPSS is slightly different. Use the Srcshell XML editor and type the following commands:

<spss name="ive_examples">

/* iveware examples - spss version */

/* import the input datasets */

get translate file="mydata2.txt" /type=tab /fieldnames.
save outfile="mydata2.sav".

/* run iveware */

/* multiple imputation */

<impute name="impute">
title Multiple imputation;
datain mydata2;
dataout impute;
default continuous;
categorical casecnt gender race3 hyper diab smoke fammi
edusubj3 cholesth;
mixed cafftot alcohol3;
transfer studyid;
restrict numcig(smoke=2,3) yrssmoke(smoke=2,3);
bounds numcig(>0) yrssmoke(>0,<=age-12) fatindex(>0)
cafftot(>=0) alcohol3(>=0);
maxpred redtot(3) wgtkg(2);
minrsqd .01;
iterations 5;
multiples 5;
seed 2001;
run;
</impute>

</spss>

Click ”run”. When SPSS opens its interactive command window, select ”all” and click the ”run” icon to execute the commands.

A successful run of Srcshell with SPSS creates an SPSS setup file called ive_examples.sps for this example. You can modify the file in the future and run without Srcshell by issuing the following command:

spss ive_examples.sps

Some users may prefer to run using the editor in SPSS without using the Srcshell editor. The following commands illustrate the use of the SPSS editor. Change to the working directory and use the SPSS Syntax Editor to create and save an Impute setup file (say, “impute.set”) with the following structure:

title Multiple imputation;
datain mydata2;
dataout impute;
default continuous;
categorical casecnt gender race3 hyper diab smoke fammi
edusubj3 cholesth;
mixed cafftot alcohol3;
transfer studyid;
restrict numcig(smoke=2,3) yrssmoke(smoke=2,3);
bounds numcig(>0) yrssmoke(>0,<=age-12) fatindex(>0)
cafftot(>=0) alcohol3(>=0);
maxpred redtot(3) wgtkg(2);
minrsqd .01;
iterations 5;
multiples 5;
seed 2001;
run;

Using the Syntax Editor, create and save an SPSS setup file (say, “ive example.sps”) with the following commands.

begin program.
import sys
sys.path.insert(0, ’~/srclib/spss’)C
import srclib
end program.

/* iveware examples - spss version */

/* import the input datasets */

get translate file="mydata2.txt" /type=tab /fieldnames.
save outfile="mydata2.sav".

/* run iveware */

/* multiple imputation */

begin program.
srclib.impute(name="impute")
end program.

Select ”all” and click the ”run” icon. For

~/srclib

use the exact path of the installation directory of IVEware.

Back to top

1.4.4 Stata and IVEware

To run Stata with the Srcshell XML editor, type the following commands:

<stata name="ive_examples">

/* iveware examples - stata version */

/* import the input datasets */

insheet using mydata2.txt, clear names case tab
save mydata2, replace

/* run iveware */

/* multiple imputation */

<impute name="impute">
title Multiple imputation;
datain mydata2;
dataout impute;
default continuous;
categorical casecnt gender race3 hyper diab smoke fammi
edusubj3 cholesth;
mixed cafftot alcohol3;
transfer studyid;
restrict numcig(smoke=2,3) yrssmoke(smoke=2,3);
bounds numcig(>0) yrssmoke(>0,<=age-12) fatindex(>0);
cafftot(>=0) alcohol3(>=0);
maxpred redtot(3) wgtkg(2);
minrsqd .01;
iterations 5;
multiples 5;
seed 2001;
run;
</impute>

</stata>

Click ”run”. Once you’ve run Srcshell, a Stata setup file called “ive examples.do’ is created. As with other packages, you can modify the file for future use with any editor and run using the following commands:

stata ive_examples.do

As in the case of other software, IVEware can be run using the Stata built-in editor. To do so, change to the working directory and utilize the Stata do-file editor to create and save an Impute setup file (“impute.set”) with the following structure:

title Multiple imputation;
datain mydata2;
dataout impute;
default continuous;
categorical casecnt gender race3 hyper diab smoke fammi
edusubj3 cholesth;
mixed cafftot alcohol3;
transfer studyid;
restrict numcig(smoke=2,3) yrssmoke(smoke=2,3);
bounds numcig(>0) yrssmoke(>0,<=age-12) fatindex(>0)
cafftot(>=0) alcohol3(>=0);
maxpred redtot(3) wgtkg(2);
minrsqd .01;
iterations 5;
multiples 5;
seed 2001;
run;

In the do-file editor, open or create a Stata setup file with the following structure:

global srclib "~/srclib/stata"

/* iveware examples - stata version */

/* import the input datasets */

insheet using mydata2.txt, clear names case tab
save mydata2, replace

/* run iveware */

/* multiple imputation */

global name "impute"
do $srclib/impute

Click ”run”. As before,

~\srclib

is the name of the IVEware installation directory.

Back to top

1.5 How to run IVEware as stand-alone

IVEware can be used as stand-alone software (SRCWARE) for performing multiple imputation (using the IMPUTE module) and perform analyses using DESCRIBE, BBDESIGN, REGRESS, SYNTHESIZE, or COMBINE, with or without incorporation of complex design features. This section provides example code for reading the data from a text file and performing multiple imputation. See later chapters for additional examples of code and output for other analyses/modules. Like other software packages, SRCWARE can be run using the XML editor or through creation of a setup file using any text editor executed in a command window.

First, click on the Srclib icon and choose “File” and “New” to create a new command file. The GETDATA module is used to read a text file containing data, and subsequently attach variable name, type (character or numeric) and formats (optional). The user can specify the delimiter as comma (“csv”), space (“\s”), tab (“\t”) etc., and the number of rows to be skipped prior to reading data from the text file. The following commands read the example file “myfile2.txt” provided with the software and also described in Section 1.4:

<srcware name="ive\_examples">
/* iveware examples - srcware version */

/* import the input datasets */

<getdata name="mydata2">
data mydata2.txt;
metadata;
delim "\t";
skip 1;
variables
name=STUDYID type=char;
name=CASECNT type=num;
name=AGE;
name=GENDER;
name=RACE3;
name=HYPER;
name=DIAB;
name=SMOKE;
name=NUMCIG;
name=YRSSMOKE;
name=FATINDEX;
name=FAMMI;
name=EDUSUBJ3;
name=DHA_EPA;
name=REDTOT;
name=CHOLESTH;
name=CAFFTOT;
name=WGTKG;
name=TOTLKCAL;
name=ALCOHOL3;
name=HGTCM;
end;
run;
</getdata>

Note that “skip 1;” instructs GETDATA to skip the first row and the “delim “\t” ” states that this is tab-delimited data. The keyword “metadata” begins entering of information about the data, and the keyword “variables” indicates the beginning of establishing the name and type of the variables in the columns through use of the keywords “name” and “type”. Finally, “end” closes the entering of metadata. The full extent of what can be specified under “metadata” keyword is specified below:

metadata
variables
name=gender
type=num
label="Respondent’s Gender"
codeframe=sexfmt
location=number
width=number
decimals=number
missing=-9;
codeframe sexfmt 1 male 2 female -9 missing;
end;

The above defines the name, type, label and format of the variable “gender”. For nondelimited data, location number indicates the starting location column number for the variable and width number specifies the width of the given variable. This feature cannot be used with delimited data. The default location number is 1 for the first variable. In general, the location for any variable is the previous variable location plus the width of the previous variable. Decimals Number is used to specify the number of implicit decimal places for the variable. This defaults to 0 for character and non-consecutive variables, and to the previous number of decimals for non-character variables after the first in a series. The missing data value for the variable is ”.” or any other missing data type of character(s) such as .N or .J. with a default of none.

Another option is to put the variable names as the first row and use the following code to read the data set:

<getdata name="mydata2">
table mydata2.txt;
</getdata>

The following code is then used to specify the multiple imputation:

/* run iveware */

/* multiple imputation */

<impute name="impute">
title Multiple imputation;
datain mydata2;
dataout impute;
default continuous;
categorical casecnt gender race3 hyper diab smoke fammi
edusubj3 cholesth;
mixed cafftot alcohol3;
transfer studyid;
restrict numcig(smoke=2,3) yrssmoke(smoke=2,3);
bounds numcig(>0) yrssmoke(>0,<=age-12) fatindex(>0)
cafftot(>=0) alcohol3(>=0);
maxpred redtot(3) wgtkg(2);
minrsqd .01;
iterations 5;
multiples 5;
seed 2001;
run;
</impute>

</srcware>

To execute, save the file and click “Run”.

Back to top

1.6 Reading and Writing Other Software Formats

It may be easier to use some other software to write to a file that can be read by IVEware. This section provides some useful commands for importing and exporting data to other popular software packages.

  1. To write a Gauss data set as a tab-delimited text table that can be read by Srcware, run the following Gauss command:

    rc = export(mydata, "mydata.txt", mynames)

    To read a tab-delimited text table created by Srcware, run the following Gauss command:

    {mydata, mynames} = import("mydata.txt", 0, 1)

  2. To write an R data set as a tab-delimited text table that can be read by Srcware, run the following R command:

    write.table(mydata, file="mydata.txt", na="", row.names=FALSE, qmethod="double", sep="\t")

    To read a tab-delimited text table created by Srcware, run the following R command:

    mydata<-read.table("mydata.txt", header=TRUE, sep="\t")

  3. To write a SAS data set as a tab-delimited text table that can be read by Srcware, define the library and run the following SAS program:

    proc export data=mylib.mydata outfile=’mydata.txt’
    dbms=tab replace; run;

    To read a tab-delimited text table created by Srcware, define the library and run the following SAS program:

    proc import datafile=’mydata.txt’ out=mylib.mydata dbms=tab
    replace; getnames=yes; run;

    Specify ”-noterminal” in the SAS invocation to export/import delimited data sets in non-interactive command-line mode.

  4. To write an S-Plus data set as a tab-delimited text table that can be read by Srcware, define the library and run the following S-Plus command:

    write.table(mydata, file="mydata.txt", dimnames.write="col",
    na="", sep="\t")

    To read a tab-delimited text table created by Srcware, define the library and run the following S-Plus command:

    mydata<-read.table("mydata.txt", header=T, row.names=NULL,
    sep="\t")

  5. To write an SPSS data set as a tab-delimited text table that can be read by Srcware, run the following SPSS command:

    save translate outfile="mydata.txt" /type=tab /fieldnames
    /replace.

    To read a tab-delimited text table created by Srcware, run the following SPSS command:

    get translate file="mydata.txt" /type=tab /fieldnames.

    The “get” translate function exists only in the Windows implementation of SPSS.

  6. To write a Stata data set as a tab-delimited text table that can be read by Srcware,
    open the data set in Stata and run the following command:

    outsheet using "mydata.txt", replace nolabel

    To read a tab-delimited text table created by Srcware, run the following Stata command:

    insheet using "mydata.txt", clear

  7. To write a SUDAAN data set as a tab-delimited text table that can be read by Srcware, save it as a SAS data set and run the following SAS program:

    proc export data=mylib.mydata outfile=’mydata.txt’ dbms=tab
    replace; run;

    To read a tab-delimited text table created by Srcware, read it as a SAS data set after running the following SAS program:

    proc import datafile=’mydata.txt’ out=mylib.mydata dbms=tab
    replace; getnames=yes; run;

Back to top