We have client ID numbers that are 7 digits long. I want a new variable
that just has the last 2 digits.
For Example:
Old Variable New Variable
4387801 01
This assumes your original ID variable is numeric, and always has 7
digits.
* --------------------------------------- .
data list list /id (f7.0).
begin data
4387801
end data.
string newid(a2).
compute newid = substr(string(id,f7),6,2).
list.
* --------------------------------------- .
If the original ID variable is already a string variable, change the
COMPUTE to:
compute newid = substr(id,6,2).
--
Bruce Weaver
bwe...@lakeheadu.ca
www.angelfire.com/wv/bwhomedir
with the variable name so it does this for the entire column instead of
for the numbers listed. I'm not sure if that was what it was supposed
to do but it did. I also tried entering the lowest and highest numbers
but I only got results for those two. It is numeric and always 7 digits
also.
2345267 67
4566283 83
8458746 46
6474823 23
Are we having fun yet????
Neila
Everything from "data list" to "end data" was just a way to get some
data into the data editor for demonstration purposes. I assume you have
your real data in a file already, so you can omit those lines.
Right, I forgot about that N-format, which ensures that leading 0's are
displayed. I.e., if the first ID number was 2345207, SMACKME would
display as 07 (because of the N2 format).
num7 smackme
2345207 07
4566283 83
8458746 46
6474823 23