Discussion:
Deleting lots of variables starting with the same letters
(too old to reply)
g***@gmail.com
2018-10-31 11:22:57 UTC
Permalink
Hello,

I have a huge dataset with many variables I don't need. They all start with the same two letters CR (no other variables starts with the same letters).

But they don't follow an order (for example I have CR 123Q23 CR45T64 etc..) I'd like to know if there is a simple way to delete all variable in SPSS starting with the same prefix?

Many thansk for the help!
Ki
2018-10-31 18:03:07 UTC
Permalink
Post by g***@gmail.com
Hello,
I have a huge dataset with many variables I don't need. They all start with the same two letters CR (no other variables starts with the same letters).
But they don't follow an order (for example I have CR 123Q23 CR45T64 etc..) I'd like to know if there is a simple way to delete all variable in SPSS starting with the same prefix?
Many thansk for the help!
you could sort and then delete. You have to be sure that no variable that starts with "cr" is part of variables to keep.

**********.

sort variables by name.

delete variables CRvar_first to CRvar_last.

**********.

By 'huge' mean hundreds, thousands?
Rich Ulrich
2018-11-01 18:20:22 UTC
Permalink
Post by g***@gmail.com
Hello,
I have a huge dataset with many variables I don't need. They all start with the same two letters CR (no other variables starts with the same letters).
But they don't follow an order (for example I have CR 123Q23 CR45T64 etc..) I'd like to know if there is a simple way to delete all variable in SPSS starting with the same prefix?
Many thansk for the help!
I've never needed to do that, but -
You can do that using Python. Jon has given examples in
the SPSS-X list.

For a one-time shot, I might just sort the variables and delete,
as suggested by Ki.
--
Rich Ulrich
Ki
2018-11-01 18:29:44 UTC
Permalink
Post by Rich Ulrich
Post by g***@gmail.com
Hello,
I have a huge dataset with many variables I don't need. They all start with the same two letters CR (no other variables starts with the same letters).
But they don't follow an order (for example I have CR 123Q23 CR45T64 etc..) I'd like to know if there is a simple way to delete all variable in SPSS starting with the same prefix?
Many thansk for the help!
I've never needed to do that, but -
You can do that using Python. Jon has given examples in
the SPSS-X list.
For a one-time shot, I might just sort the variables and delete,
as suggested by Ki.
--
Rich Ulrich
Rich, you are right! About 8 years ago I posted a similar question that you, Jon and other helped me solve. The 2010 post title is:
"How to drop variables with all system missing values"
And, this was a few dozen variables with random names that had all sysmis values. The names did not have a 'nice' names with CR initials, so in that case, the Phyton was the solution.
Loading...