Srcware User Guide

Srcware is public-use software to provide a framework and handle import and export of data and metadata for IVEware, Search and other SRC/SMP procedures. Normally it is used only with these procedures. See Importing and exporting data below for a description of ways to exchange data and metadata between Srcware and other software systems.

Srcware invocation

Srcware may be invoked at a Linux, Mac OS X or Windows command line with the following command:

srcware file /batch

The call parameters are as follows:

file The path of the Srcware setup file (required)
/batch Specifies a batch run, so don't write to the screen (optional)

Srcware may also be invoked in a Linux graphical user interface or Windows by copying and pasting or dragging the setup file to the Srcware executable file or an icon pointing to it.

Srcware commands

Describe

Describe is invoked within Srcware with the following command:

%describe(name= , dir= , setup= );

The call parameters and setup are as in the IVEware User Guide.

Impute

Impute is invoked within Srcware with the following command:

%impute(name= , dir= , setup= );

The call parameters and setup are as in the IVEware User Guide.

Regress

Regress is invoked within Srcware with the following command:

%regress(name= , dir= , setup= );

The call parameters and setup are as in the IVEware User Guide.

Search

Search is invoked within Srcware with the following command:

%search(name= , dir= , setup= );

The call parameters and setup are as in the Search User Guide.

Getdata

Getdata is invoked within Srcware with the following command:

%getdata(name= , dir= , setup= );

The call parameters are as follows:

Name The name to be used with various extensions to identify the files associated with the step.
Dir The directory path for the files associated with the step.
Setup Specify "new" to indicate that the setup statements follow. Specify "old" to indicate that the setup statements are in a separate file [name].set in directory [dir].

Getdata statements

The following statements may be specified in a getdata setup, either as part of the Srcware setup or in a separate file. The statements are written in the form:

Keyword parameter(s);

A getdata setup must have 1) either a metadata and a data statement or a table statement, and 2) a run statement. The other statements are optional. A statement may span more than one line, and more than one statement may be specified on a line.

Keyword Parameters Function
Data File(s) The path(s) of the data file(s) to be read.
Delimliter Character(s) "CSV" to indicate comma-separated variables or the character(s) used to delimit variable-length data. If a data item includes a delimiter, it must be enclosed in quotation marks. "\t" indicates a tab character.
Metadata File The path of the metadata file to be read. If the file is omitted, the metadata statements must follow immediately. The metadata statements are described below.
End   Terminates the metadata statements, if they are inline.
Nobs Number The number of observations to be included in the output data file. If this statement is omitted, all the observations in the input dataset(s) will be included.
Print None
Standard
Details
All
The printout desired. None. Standard: Summary information about the dataset. Details and all: Summary information about the dataset and detailed information about the variables and codeframes. Defaults to standard.
Subset Variable list The list of variables to be included in the output data file. If this statement is omitted, all the variables described in the metadata will be included.
Table File(s) The path(s) of the table file(s) to be read. The data must be in spreadsheet table form with the first row of each table containing the variable names. The names of character variables must be preceded by "$". The table cells must be delimited by blanks, commas or tab characters. Cells whose values include blanks, commas or tab characters must be enclosed in double or single quotation marks.
Title Text The text to be used as the title for the step.
Run   Required. Must be the last statement in the getdata setup.

Metadata statements

Metadata statements may be specified either as part of the getdata setup or in a separate file. A statement may span more than one line, and more than one statement may be specified on a line.

Keyword Parameters Function
Delimliter Character(s) "CSV" to indicate comma-separated variables or the character(s) used to delimit variable-length data. If a data item includes a delimiter, it must be enclosed in quotation marks. "\t" indicates a tab character.
ID Variable The ID variable. Defaults to the observation number _OBS_.
Multiple Variable For multiple input files, the variable to contain the multiple number. Defaults to _MULT_.
RecordlengthNumber The record length for binary and other fixed-length records.
Standard   Specifies that the metadata/data files are in the Srcware standard form produced by Getdata.
Variable(s) Description The variable description, whose parameters are described below. The keyword "variable" may be omitted for variable statements after the first in a sequence.
Codeframe(s) Description The codeframe description, whose parameters are described below. The keyword "codeframe" may be omitted for codeframe statements after the first in a sequence.

Variable parameters

Keyword Parameters Function
Name Variable name The variable name. Required.
Label Text The variable label. Defaults to blank.
Type Character
Numeric
Integer
Floating
The variable type. ASCII character, ASCII numeric, binary integer, or binary floating-point. Binary integer and floating-point may not be used with delimited data. Optional. Defaults to numeric for the first variable and the previous variable type thereafter.
Codeframe Codeframe name Specifies the use of a codeframe for the variable. No default.
Location Number The starting location for the variable. May not be used with delimited data. For non-delimited data, the location defaults to 1 for the first variable and to the previous variable location plus the previous variable width thereafter.
Width Number The width of the variable. May not be used with delimited data. For non-delimited data, the width defaults to 1 for the first variable and to the previous variable width thereafter.
Decimals Number The number of implicit decimal places for the variable. 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.
Missing Value The missing data value for the variable. May be "." or any other character(s). Defaults to none.

Codeframe parameters

Keyword Parameters Function
Name Codeframe name The codeframe name. Required.
Label Text The codeframe label. Defaults to blank.
Value Text The code value and its label. At least two value/label pairs are required.

Example

%getdata(name=myinput, dir=/mydirectory, setup=new);
title Read ASCII data;
datain /mydirectory/myinput.txt;
metadata;
  variables
    name Name
    label "Respondent's name"
    type character
    ;
    name Age
    label "Respondent's age"
    type numeric
    missing 999
    ;
    name Sex
    label "Respondent's sex"
    codeframe Sex
    missing 9
    ;
  codeframe
    name Sex
    label "Respondent's sex"
    1 Female
    2 Male
    9 Missing
    ;
  variable
    name Income
    label "Respondent's income"
    missing -999999999
    ;
end;
run;

Putdata

Putdata is invoked within Srcware with the following command:

%putdata(name= , dir= , setup= );

The call parameters are as follows:

Name The name to be used with various extensions to identify the files associated with the step.
Dir The directory path for the files associated with the step.
Setup Specify "new" to indicate that the setup statements follow. Specify "old" to indicate that the setup statements are in a separate file [name].set in directory [dir].

Putdata statements

The following statements may be specified in a putdata setup. The statements are written in the form:

Keyword parameter(s);

A putdata setup must have 1) a datain statement or an imputation statement, and 2) a run statement. The other statements are optional. A statement may span more than one line, and more than one statement may be specified on a line.

Keyword Parameters Function
Datain File The path of the data/metadata files to be read.
Dataout File The path of the data/metadata files to be written. If no dataout statement is present, the output file(s) will have the same directory and name as the setup with .met and .dat suffixes for metadata/data files.
Delimliter Character(s) "CSV" to indicate comma-separated variables or the character(s) used to delimit variable-length data. If a data item includes a delimiter, it must be enclosed in quotation marks. "\t" indicates a tab character.
Imputation File The path of the imputation file to be read.
Mult Number
All
The imputation multiple(s) to be included in the output data file. All specifies that all multiples are to be included. If this statement is omitted, the first multiple will be included.
Nobs Number The number of observations to be included in the output data file. If this statement is omitted, all the observations in the input dataset(s) will be included.
Print None
Standard
Details
All
The printout desired. None. Standard: Summary information about the dataset. Details and all: Summary information about the dataset and detailed information about the variables and codeframes. Defaults to standard.
Table File Specifies that the output dataset will be in spreadsheet table form. The first row of the table will contain the variable names. The table cells will be delimited by tab characters, commas or spaces. If no file path is present, the output table will have the same directory and name as the setup with a .txt suffix.
Title Text The text to be used as the title for the step.
Run   Required. Must be the last statement in the getdata setup.

Example

%putdata(name=myoutput, dir=/mydirectory, setup=new);
title Write all multiples;
imputation /mydirectory/myimputation;
dataout /mydirectory/myoutput;
multiples all;
print all;
run;width="144"

Importing and exporting data

The Srcware procedures Getdata and Putdata and analogous procedures in other software can be used to exchange data and the full panoply of metadata (labels, codeframes, etc.) among systems. But the simplest way to exchange data and minimal metadata is as a spreadsheet-style delimited text table with the variable names in the first row. Most windowing database management and spreadseet programs can exchange data in this format via their file saveas/open or export/import menus. Many statistical software packages can export and import data in this format too, via menus or commands. Following are the commands needed for several well-known packages. Substitute real names for the arbitrary names mydata, mynames and mylib.

Srcware

To write an Srcware dataset as a tab-delimited text table that can be read by other software, run the following Srcware command:

%putdata; datain mydata; table mydata.txt; run;

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

%getdata; dataout mydata; table mydata.txt; run;

Gauss

To write a Gauss dataset 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)

R

To write an R dataset 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")

SAS

To write a SAS dataset 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 datasets in non-interactive command-line mode.

S-Plus

To write an S-Plus dataset 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")

SPSS

To write an SPSS dataset 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.

Stata

To write a Stata dataset as a tab-delimited text table that can be read by Srcware, open the dataset 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

SUDAAN

To write a SUDAAN dataset as a tab-delimited text table that can be read by Srcware, save it as a SAS dataset 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 dataset after running the following SAS program:

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

Last updated 23 October 2014