*Created 2014_01_30 by Ruben Geert van den Berg, www.spss-tutorials.com. *Contains all syntax used in http://www.spss-tutorials.com/spss-string-variables-basics/. *1. Show formats of string variables in data. display dictionary. *1. Create empty new string variable with string command. string string_3(a10). *2. Pass values into new string variable. compute string_3 = 'Hello'. exe. *Convert numeric_1 to (existing) string variable with string function. compute string_3 = string(numeric_1,f3). exe. *1. Compute empty flag variable for flagging cases called Stefan. compute find_stefan = 0. exe. *2. Wrong way: without quotes Stefan is thought to be variable name. if string_2 = Stefan find_stefan = 1. exe. *3. Right way: quotes around Stefan. if string_2 = 'Stefan' find_stefan = 1. exe. *1. Compute empty flag variable. compute find_chrissy = 0. exe. *2. Line below doesn't flag any cases because 'chrissy' is not the same as 'Chrissy'. if string_2 = 'chrissy' find_chrissy = 1. exe. *3. Right way: 'Chrissy' instead of 'chrissy'. if string_2 = 'Chrissy' find_chrissy = 1. exe. *No system missing values in string variables. frequencies string_2. *Specify user missing values in string variable. missing values string_2(''). *Rerun frequency table. frequencies string_2. *Sort cases by string numbers. sort cases by string_1. *Calculation crashes with error #4307. compute string_1 = string_1 * 2. *Descriptives crashes with warning. descriptives string_1.