SPSS Main Numeric Functions

This tutorial covers some obvious and some less obvious functions for editing numeric variables. You can follow along with this tutorial by downloading and opening hospital.sav. They syntax we’ll use can be copy-pasted or downloaded here. Specifying User Missing Values This tutorial will only use the last 2 variables in the data.* Before doing anything else, we first specify […]

SPSS RANGE Function – Quick Tutorial

COMPUTE v2 = RANGE(V1,2,4). SPSS RANGE Function Result Summary SPSS’ RANGE function is used to evaluate whether or not values are within a given range. Test values equal to the lower or upper boundary are also within the given range. Run the syntax below for a quick demonstration. SPSS Range Syntax Example *1. Create couple of cases. data list free/v1(f1). begin […]

SPSS INSERT Command

Definition SPSS Insert is a command for running syntax files from within another syntax file. This may help keeping your syntax organized. SPSS Insert Command – Why Use It? Executing all of your commands from syntax may be the single best practice for working with SPSS. One of the reasons is that you can correct steps early […]

SPSS REPLACE Function

Definition SPSS REPLACE replaces a substring in a string by a different (possibly empty) substring. SPSS Replace – Removing Spaces URLs are created from “title” by using REPLACE. The syntax below demonstrates how to do this. We have a dataset holding the titles of web pages and we’d like to convert these to URLs. For one thing, we don’t like spaces in […]

SPSS INDEX Function

Summary The SPSS INDEX function returns the position of the first occurrence of a given expression within a string. If the expression does not occur in the string, it returns a zero. As a rule of thumb, always use it as CHAR.INDEX. The reason for this is explained SPSS Unicode Mode. Note that string values are case sensitive. SPSS Index […]

SPSS – Quick Overview Statistical Functions

This tutorial walks you through SPSS’ main statistical functions. They are mainly used with COMPUTE and IF. Note that these are all within-subjects (or “horizontal”) functions. For between-subjects (or “vertical”) functions, see AGGREGATE. All examples in this tutorial use hospital.sav, which is freely downloadable. Within-subjects versus between-subjects functions. SPSS Statistical Functions – Missing Values SPSS statistical functions only return system missing values if all their input values […]

SPSS Missing Values Functions

Most real world data contain some (or many) missing values. It’s always a good idea to inspect the amount of missingness for avoiding unpleasant surprises later on. In order to do so, SPSS has some missing values functions that are mostly used with COMPUTE, IF AND DO IF. This tutorial demonstrates how to use them effectively. We’ll do so […]

SPSS Main Numeric Functions

This tutorial covers some obvious and some less obvious functions for editing numeric variables. You can follow along with this tutorial by downloading and opening hospital.sav. They syntax we’ll use can be copy-pasted or downloaded here. Specifying User Missing Values This tutorial will only use the last 2 variables in the data.* Before doing anything else, we first specify […]

JavaScript Function Apply

Method Reuse With the apply() method, you can write a method that can be used on different objects. The JavaScript apply() Method The apply() method is similar to the call() method (previous chapter). In this example the fullName method of person is applied on person1: Example var person = { fullName: function() { return this.firstName + ” ” + this.lastName; } } var person1 = { firstName: “Mary”, lastName: “Doe”, } person.fullName.apply(person1);  // Will return “Mary Doe” Try it […]

JavaScript Function Call

Method Reuse With the call() method, you can write a method that can be used on different objects. All Functions are Methods In JavaScript all functions are object methods. If a function is not a method of a JavaScript object, it is a function of the global object (see previous chapter). The example below creates an […]

JavaScript Function Invocation

The code inside a JavaScript function will execute when “something” invokes it. Invoking a JavaScript Function The code inside a function is not executed when the function is defined. The code inside a function is executed when the function is invoked. It is common to use the term “call a function” instead of “invoke a function“. It […]

JavaScript Function Definitions

JavaScript functions are defined with the function keyword. You can use a function declaration or a function expression. Function Declarations Earlier in this tutorial, you learned that functions are declared with the following syntax: function functionName(parameters) { code to be executed } Declared functions are not executed immediately. They are “saved for later use”, and will be executed later, when they are invoked (called upon). […]

JavaScript Function Parameters

A JavaScript function does not perform any checking on parameter values (arguments). Function Parameters and Arguments Earlier in this tutorial, you learned that functions can have parameters: functionName(parameter1, parameter2, parameter3) { code to be executed } Function parameters are the names listed in the function definition. Function arguments are the real values passed to (and received by) the function. Parameter Rules JavaScript function definitions […]

JavaScript Functions

A JavaScript function is a block of code designed to perform a particular task. A JavaScript function is executed when “something” invokes it (calls it). Example function myFunction(p1, p2) { return p1 * p2;              // The function returns the product of p1 and p2 } Try it Yourself » JavaScript Function Syntax A JavaScript function is defined […]