spssdictionary.SetMultiResponseSet Function (R)

spssdictionary.SetMultiResponseSet(datasetName,mrsetName,mrsetLabel,codeAs,countedValue,elementaryVars). Defines multiple response sets. This function is used to define multiple response sets for new IBM® SPSS® Statistics datasets created with the SetDictionaryToSPSS function.

  • The argument datasetName is the name of the IBM SPSS Statistics dataset as specified on the call to the SetDictionaryToSPSS function used to create the dataset.
  • The argument mrsetName is the name of the multiple response set and is a string of maximum length 63 bytes that must follow IBM SPSS Statistics variable naming conventions. If the specified name does not begin with a dollar sign ($), then one is added. If the name refers to an existing set, the set definition is overwritten.
  • The optional argument mrsetLabel is a string specifying a label for the set, and cannot be wider than the limit for IBM SPSS Statistics variable labels.
  • The argument codeAs specifies the variable coding and must be "Dichotomies" (multiple dichotomy set) or "Categories" (multiple category set).
  • The argument countedValue specifies the value that indicates the presence of a response for a multiple dichotomy set. This is also referred to as the “counted” value. If the set type is numeric, the value can be an integer or a string respresentation of an integer. If the set type is string, the value, after trimming trailing blanks, cannot be wider than the narrowest elementary variable. countedValue is required if codeAs has the value "Dichotomies" and is ignored otherwise.
  • The argument elementaryVars is a character vector specifying the list of elementary variables that define the set (the list must include at least two variables). Variables can be specified by name or index value (index values represent position in the dataset, starting with 0 for the first variable in file order). When specifying variable names, you can use TO to indicate a range of variables--for example, elementaryVars=c("age TO income") specifies age, income, and all variables between them in the active dataset's dictionary. Variable names must match case with the names as they exist in the active dataset's dictionary. All specified variables must be of the same type (numeric or string).
  • The SetMultiResponseSet function should be called after SetDictionaryToSPSS and before calling EndDataStep.

Example

var1 <- c("Newspaper","",0,"F1","scale")
var2 <- c("TV","",0,"F1","scale")
var3 <- c("Web","",0,"F1","scale")
dict <- spssdictionary.CreateSPSSDictionary(var1,var2,var3)
spssdictionary.SetDictionaryToSPSS("results",dict)
spssdictionary.SetMultiResponseSet(datasetName="results",
                                   mrsetName="$mltnews",
                                   mrsetLabel="News Sources",
                                   codeAs="Dichotomies",
                                   countedValue=1,
                                   elementaryVars=c("Newspaper","TV","Web"))
spssdictionary.EndDataStep()