IBM Support

Counting non-blank string variable information

Troubleshooting


Problem

I have six string variables (SCH1, SCH2, SCH3, SCH4, SCH5, SCH6). I would like to count the number of responses across all six variables, excluding instances where the response has been left blank. Even under Data->Count, I can only look for specific characters and combinations thereof, how can I count valid values only?

Resolving The Problem

We need to do a bit of reverse thinking. Using the Count Command, you are unnable to count completed values per variable, so you can count missing or blank values.

COUNT
newvar = SCH1 SCH2 SCH3 SCH4 SCH5 SCH6 (' ') .
EXECUTE.

The number of missing cells across the rows is represented in the variable NEWVAR.
Next you will subtract the number of variables being examined (6) from NEWVAR to get the final number of valid non-missing cells from left to right, per case, called CTVAR.
COMPUTE CTVAR = 6 - newvar .
EXECUTE .

Your final syntax should follow this format to get the total row count of non-missing variables.

COUNT
newvar = SCH1 SCH2 SCH3 SCH4 SCH5 SCH6 (' ') .
COMPUTE CTVAR = 6 - newvar .
EXECUTE

[{"Product":{"code":"SSLVMB","label":"IBM SPSS Statistics"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Component":"Not Applicable","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"Not Applicable","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

Historical Number

63274

Document Information

More support for:
IBM SPSS Statistics

Software version:
Not Applicable

Document number:
418949

Modified date:
16 April 2020

UID

swg21477532

Manage My Notification Subscriptions