A variable from one of your data files, as in each row in the Variables and Questions tab. Every variable has an associated Question object.
Get/set the variable's comment (free text). Any formatting seen in Q will be lost - this is plain text only.
Returns the number of unique values contained in this variable's data.
Deletes this variable. This does not work with variables from the raw data, only copied or constructed variables.
Duplicates this variable and puts it in a single-variable question. This is the same as using "Copy and Paste Variable(s) | Exact" in Q. The new variable will be positioned directly below the variable it is copied from.
|Returns:||The new Variable object.|
Creates a new variable from this variable, but changes the type of the new variable to variable_type. This functions as in Q, so a Categorical variable created from a Text variable will automatically code the text variable, a Date variable created from a Text varible will try to automatically determine the date format, etc.
|variable_type||The the same text you see in the Variable Type column in Q. e.g 'Money', 'Categorical', 'Text'.|
|Returns:||A new Variable object.|
Whether two objects are the same.
|Returns:||true or false|
Get the question's internal unique identifier.
Get/set the variable's label. This will not automatically rename the question too, as it does in Q desktop for single-variable questions.
Get/set the variable's name.
Get or set whether the variable has a Status of CHECK or not
v.needsCheck = false
Gets the periods that result from the date configuration in a Date variable. These are the periods that would be used as an axis on a chart, and take into account the date range of the data, as well as the aggregation options configured for the variable. Example calculation: If the data is in the range midnight 22 Jun 2007 to midnight 25 Jun 2007, set up with a 1 day aggregation and period type of "All Data", then the text of the periods returned by this property would be: Period 1: '6/22/2007 12:00:00 AM - 6/22/2007 11:59:59 AM' Period 2: '6/23/2007 12:00:00 AM - 6/23/2007 11:59:59 AM' Period 3: '6/24/2007 12:00:00 AM - 6/24/2007 11:59:59 AM' Period 4: '6/25/2007 12:00:00 AM - 6/25/2007 11:59:59 AM'
|Returns:||An array of QScriptPeriodInfo objects for a date question. Returns null for any other type of question.|
var periods = variable.periods; var first_period_text = periods.labelText; var first_period_start = periods.start; var first_period_end = periods.end;
Get the Question object that this variable is part of.
Returns the list of raw values contained in this variable's data. These are the "source" values from the raw data, and no recoding will be applied (i.e. the 'valueAttributes' have no affect on these values). If you require the current recoded values, you must use the 'valueAttributes' property and manually recode these source values.
Returns the list of unique values contained in this variable's data. These are the "source" values from the raw data, and no recoding will be applied (i.e. the 'valueAttributes' have no affect on these values). If you require the current recoded values, you must use the 'valueAttributes' property and manually recode the unique source values.
Gets the ValueAttributes object for just this variable. If this variable is part of a question containing multiple values then you should probably be using question.valueAttributes() instead.
Get or sets the variable's type. This can be one of 'Numeric', Text, Categorical, 'Ordered Categorical', 'Money' or 'Date'. Be aware that if the original variable type is 'Text' then you should instead use the function duplicateAs() to convert it to a categorical, numeric, or date variable.
v.variableType = "Categorical"