• Intro to AutoHotkey HotStrings with AutoHotkey Intermediate AutoHotkey Intermediate Objects GUIs are Easy w/AutoHotkey Intro to DOS & AutoHotkey AutoHotkey FAQ1 AutoHotkey FAQ2

Syntax for changing width of SPSS string variable

SPSS string variableUse Syntax to change the with of SPSS string variable

String variables in SPSS are still a pain to deal with and merging data files together with a key variable that is a string is NOT fun in SPSS.  The string variable needs to be the same width in each data file and needs to be sorted the same (ascending-descending).  I can’t tell you the number of times I’d curse the old format!

My below macro makes it a breeze to change the width of your SPSS string variables.  The process is pretty straight forward.

Years ago I established some defaults for variables that were frequently in my data sets like: email, First name, Last name, company name, Job title, Job Role, etc.  Surprisingly setting the width to wider than they are doesn’t actually take up any extra file size so, as a rule of thumb, I recommend doubling what you typically see (otherwise you’ll end up with truncated data)

Here is the macro I use which automates the process of changing the SPSS string text width.  🙂

*///resize variable////////////.
compute newvar=!name.

!CNGWDTH Name=email   Width=A65.

BTW- if you were reading this with the goal of changing the column width of variables in the data editor (think of Excel and how you resize the columns) the above macro has nothing to do with it.  Below is the code you’d use to change email to 30 wide; Country to 20 wide; and the rest to 6 wide.

 VARIABLE WIDTH ALL (6)  email (30) country (20).

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.