BookmarkSubscribeRSS Feed
mariamon0
Fluorite | Level 6

I have a marriage variable called v1marital in one dataset and v_martial_0 in another.

I am trying to harmonize the variables and also change from character to numeric.

However, the variables have different conditions and I want vmarital=2 to equal 3 =v_marital_0. I'm not sure how to go about this.

V_MARITAL_0

1=single, never married

2=married, co-habituating

3=divorced or separated

4=widowed

and

V1MARITAL

1=single, never married

2=separate

3=divorced or annulled

4=widowed

5=married

 

1 REPLY 1
Kurt_Bremser
Super User

Keep as character.

Why? A number needs at least 3 bytes for storage, a single character just one.

Create a format that maps the 5 values to the 4 values:

proc format;
value $mconvert
  "1" = "1"
  "2" = "3"
  "3" = "3"
  "4" = "4"
  "5" = "2"
;
run;

Then you can use the put() function with the format for converting.