Recoding Other responses

Reply
Regular Contributor
Posts: 150

Recoding Other responses

I had an intern help me recode other responses on a questionnaire. We had to recode them because several interviewers were typing in responses into the other field that could have fit into a category. The intern placed several other responses into categories but now I need to delete them out of the other field since they are now recategorized. For instance:

if DGOTH3A2="DRANK" then DG6FQ3AG=1;
else if DGOTH3A2= "DRANK IT" then DG6FQ3AG=1;
else if DGOTH3A2= "DRINK" then DG6FQ3AG=1;
else if DGOTH3A2= "DRINK IT" then DG6FQ3AG=1;
else if DGOTH3A2= "DRINKING IT" then DG6FQ3AG=1;
else if DG6FQ3AA>. then DG6FQ3AG=0;

She did not include code to say, to delete the "DRANK", for instance, from the other field variable DGOTH3A2, is there a way to do that short of me writing code that says:

if DGOTH3A2="DRANK" then delete.

We have lots of these we had to do this for so any help would be greatly appreciated.

Super User
Posts: 17,835

Re: Recoding Other responses

I'm assuming its not safe to the do the inverse?

ie if DG6GFQ3AG=1 then DGOTH3A2="";

You could modify the code to something as follows:

if DGOTH3A2 in ("DRANK", "DRANK IT", "DRINK", "DRINK IT",  "DRINKING IT") then do;

      DG6FQ3AG=1;

    DGOTH3A2 = "";

end;

else if DG6FQ3AA>. then DG6FQ3AG=0;

Generally, not something I recommend anyways. You shouldn't change source data, but assuming there's a good reason that's one way.

Regular Contributor
Posts: 150

Re: Recoding Other responses

With the other options, there are more responses than just those listed, so if I have the code DGOTH3A2 = "";, will that clear out all of the responses and not just those listed?

I agree with not changing the source data but in this case, the first option for the question was "I drank it", so the other response can safely be re categorized there to have less missing data. We are also creating new variables based on the other responses for analysis purposes. Thanks for you help.

Super User
Super User
Posts: 6,500

Re: Recoding Other responses

It depends on whether they recoded when only part of the other response matched one of the categories.

For example if other='ATE AND DRANK' and they coded DRANK=1 would you want to convert other to just 'ATE'?

Try doing a proc freq to the the list of actual values.

proc freq ;

tables DGOTH3A2* DG6FQ3AG / missing;

run;

Are there other variables that they code from the other field besides just DRANK?  Perhaps you want to look at all of them?

Or perhaps you just want to clear the other variable when any of them is set?

if 0 < max(of DG6FQ3AG <other coded variables>) then DGOTH3A2;

Regular Contributor
Posts: 150

Re: Recoding Other responses

You last statement is exactly what I want to do, clear the other variable when the option is used/re-categorized.

If the other had more than 1, then it would not be re-categorized into the variable because these are all select one variables.  Will try some of the code and see what I can come up with.

Ask a Question
Discussion stats
  • 4 replies
  • 158 views
  • 0 likes
  • 3 in conversation