If I were to guess, the variable naming going on in your datasets is giving you issues. Work on getting the variable names into a standard format (starts with A-z or _ and remove any spaces) and then your problem can be solved with a left join as you have done.
Here's an example:
proc format;
value quest
11 = "11. In the past year, how many times have you been to the emergency room?"
;
value ans
1 = "Once"
2 = "Twice"
3 = "3 or more"
;
run;
data survey_resp;
input clientid question answer;
datalines;
1 11 1
2 11 3
3 11 2
;
run;
data resp_xwalk;
infile datalines dlm=',';
length question 8. answer 8. need $50. problem $100. goal $200.;
input question answer need $ problem $ goal $;
datalines;
11,1,Emergency Room Visits, Emergency Room Visits - One visit reported., Have 0 ER visits over next 60 days. See your doctor or urgent care facility when appropriate.
11,2,Emergency Room Visits, Emergency Room Visits - Two visits reported., Have 0 ER visits over next 60 days. See your doctor or urgent care facility when appropriate.
11,3,Emergency Room Visits, Emergency Room Visits - Three or more visits reported., Have 0 ER visits over next 60 days. See your doctor or urgent care facility when appropriate.
;
run;
data survey_resp_formatted(drop=question answer);
set survey_resp;
quest = put(question,quest.);
ans = put(answer,ans.);
run;
data resp_xwalk_formatted(drop= question answer);
set resp_xwalk;
quest = put(question,quest.);
ans = put(answer,ans.);
run;
proc sql;
create table want as
select a.clientid, a.quest, a.ans, b.need, b.problem, b.goal
from survey_resp_formatted a
left join resp_xwalk_formatted b
on a.quest=b.quest and a.ans=b.ans
order by a.clientid, a.quest, a.ans
;quit;
-unison
... View more