JavaScript String Reference

JavaScript Strings A JavaScript string stores a series of characters like “John Doe”. A string can be any text inside double or single quotes: var carname = “Volvo XC60”; var carname = ‘Volvo XC60’; String indexes are zero-based: The first character is in position 0, the second in 1, and so on. For a tutorial about Strings, read our JavaScript […]

SPSS Transformation Commands

Summary SPSS transformation commands (or simply “transformations”) can be loosely defined as commands that are not immediately carried out when you run them. Instead, they are kept in mind by SPSS and executed only when necessary. The table below gives an overview of SPSS’ main tranformation commands. Main SPSS Tranformation Commands COMMAND NAME GOAL TYPICAL USAGE […]

Convert String Date to SPSS Date Variable

“I’ve a string variable in my data holding dates formatted as ‘01JAN2016’ without separators between the day, month and year components. To make things worse, the month abbreviations are in Dutch and 3 of those differ from their English counterparts. How can I change this string into an SPSS date variable?” Step 1: Add Separators […]

String Variables

String variables are variables that hold zero or more characters such as letters, numbers, spaces, commas and many more. You can’t use numeric functions such as addition or subtraction on string variables. You can, however, extract one or more characters (a substring) from them, glue them together (concatenate) and a couple of other functions. Like so, working […]

SPSS – Splitting a String Variable

After importing some data into SPSS, some answers ended up in a single string variable. The data are in splitstrings.sav, part of which is shown below. Excel has a nice “text to columns” function to split it but SPSS hasn’t…So you think you can syntax?Then let’s go and split this string into the original answers. Step 1 – New […]

SPSS Python String Tutorial

The most important Python object we’ll deal with are strings. This tutorial presents a quick overview of Python string methods. However, let’s first learn some very basics. Python Strings – Basic Rules Strings may be enclosed by single or double quotes if they don’t contain any line breaks; Strings may always be enclosed by 3 single […]

How to Convert String Variables into Numeric Ones?

Converting an SPSS string variable into a numeric one is simple. However, there’s a huge pitfall that few people are aware of: string values that can’t be converted into numbers result in system missing values without SPSS throwing any error or warning. This can mess up your data without you being aware of it. Don’t believe me? I’ll demonstrate the problem -and the solution- […]

SPSS String Variables Basics

For working proficiently with SPSS string variables , it greatly helps to understand some string basics. This tutorial explains what SPSS string variables are and demonstrates their main properties. We encourage you along by downloading and opening string_basics.sav. The syntax we use can be copy-pasted or downloaded here. SPSS String Variables – What Are They? String variables are one […]

Concatenate (General Concept)

Concatenating two or more strings is creating a new string consisting of the characters of the first string followed by the characters of the subsequent string(s) in their original order. SPSS CONCAT Function Concatenating in SPSS is done by the CONCAT function. The most basic usage is COMPUTE A = CONCAT(B,C,D). Note that you can concatenate only strings. For concatenating numbers, […]

Substring (General Concept)

A substring is a subset of characters from a string. Extracting substrings in SPSS is done with CHAR.SUBSTR (SPSS versions 16+) or just SUBSTR (SPSS versions 15-). CHAR.SUBSTR takes two or three arguments as shown by the minimal example below. SPSS CHAR.SUBSTR – Minimal Example COMPUTE var_2 = CHAR.SUBSTR(var_1,3,2). The three arguments mean the following: var_1 denotes the variable […]

SPSS String Variables Tutorial

Working with string variables in SPSS is pretty straightforward if one masters some basic string functions. This tutorial will quickly walk you through the important ones. SPSS Main String Functions CHAR.SUBSTR (substring) – Extract character(s) from string CONCAT (concatenate) – Combine strings CHAR.INDEX – Find first occurrence of character(s) in string CHAR.RINDEX (right index) – Find last occurrence of character(s) in […]

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 String Methods

String methods help you to work with strings. String Methods and Properties Primitive values, like “John Doe”, cannot have properties or methods (because they are not objects). But with JavaScript, methods and properties are also available to primitive values, because JavaScript treats primitive values as objects when executing methods and properties. String Length The length property returns […]

JavaScript Strings

JavaScript strings are used for storing and manipulating text. JavaScript Strings A JavaScript string is zero or more characters written inside quotes. Example var answer = “It’s alright”; var answer = “He is called ‘Johnny’”; var answer = ‘He is called “Johnny”‘; Try it Yourself » String Length The length of a string is found in the built in property length: Example […]

JavaScript Data Types

JavaScript Data Types JavaScript variables can hold many data types: numbers, strings, objects and more: var length = 16;                               // Number var lastName = “Johnson”;                      // String var x = {firstName:”John”, lastName:”Doe”};    // Object The Concept of Data Types In programming, data types is an important concept. To be able to operate on variables, it is important to know something about the type. Without […]