Recoding a combined variable

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Recoding a combined variable

[Ela Bonbevan]
Hello all,

I have a variable that contains codes from two different time frames and
they differ in their structure.  I would to split these two types of codes
into two different variables.  The first set of codes are numeric three
digit eg 665 and the second set are combined alpha numeric (eg. 88A,
97Z).  I have managed to use the convert option to pull out all of the
three digit numeric variables and pull them into a new variable.  Is there
any way to pull out the alpha numeric variables and put them in a new
variable?

Many thanks for your help.

Diane
Toronto, Canada
Reply | Threaded
Open this post in threaded view
|

Re: Recoding a combined variable

Maguin, Eugene
Diane,

I'm not completely sure this will work but it is where I would start to work
the problem. As I understand the convert keyword, values readable with an F
format are converted their numeric representation; all other values are
coded as sysmis. You've done that and you now have one half of your problem
solved. So, you have two variables, Old and New1, where Old is the original
variable and New1 is the variable created using the convert keyword. You
want to make another variable, New2. If you were to lay Old and New1 side by
side in columns, there'd be three cases: 1) valid values converted to
numeric, 2) missing or sysmis in both, 3) valid values not converted to
numeric because they contain an alpha character. All you need to do is find
those values and put them in New2.

If (missing(New1) and not(missing(Old))) New2=Old.

Gene Maguin
Reply | Threaded
Open this post in threaded view
|

Re: Recoding a combined variable

Carlos Renato-2
In reply to this post by [Ela Bonbevan]
Dear Friend

     It's possible. Use the SUBSTR command for COMPUTE a
new variable.
Example: A variable AGESEX is "78male" if COMPUTE a new
variable COMPUTE AGE = SUBSTR(AGESEX,1,2) results in a
new variable AGE is "78".

STRING FIRST_THREE_NUMBERS (A8).
COMPUTE AGE = SUBSTR(ORIGINAL_VARIABLE,1,3) .
EXECUTE .

Carlos Renato
Statistician
Recife - PE - Brazil
[hidden email]

2006/8/18, [Ela Bonbevan] <[hidden email]>:

>
> Hello all,
>
> I have a variable that contains codes from two different time frames and
> they differ in their structure.  I would to split these two types of codes
> into two different variables.  The first set of codes are numeric three
> digit eg 665 and the second set are combined alpha numeric (eg. 88A,
> 97Z).  I have managed to use the convert option to pull out all of the
> three digit numeric variables and pull them into a new variable.  Is there
> any way to pull out the alpha numeric variables and put them in a new
> variable?
>
> Many thanks for your help.
>
> Diane
> Toronto, Canada
>



--
Carlos Renato
[hidden email]