spssdictionary.GetVariableAttributeNames Function (R)
spssdictionary.GetVariableAttributeNames(variable). Returns the names of any variable attributes for the specified variable in the active dataset. The argument can be a character string specifying the variable name or an integer specifying the index value of the variable (index values represent position in the dataset, starting with 0 for the first variable in file order). Variable names must match case with the names as they exist in the active dataset's dictionary.
- The result is a vector of the attribute names.
- If there are no attributes for the specified variable, NULL is returned.
Example
#Create a list of variables that have a specified attribute
varList <- vector()
attribute <- "demographicvars"
dict <- spssdictionary.GetDictionaryFromSPSS()
varnames <- dict["varName",]
for (name in varnames){
if (any(attribute==spssdictionary.GetVariableAttributeNames(name)))
varList <- c(varList,name)
}
{if (length(varList) > 0){
cat(paste("Variables with attribute ",attribute,":\n"))
cat(varList,sep="\n")}
else
cat(paste("No variables have the attribute ",attribute))
}