@ScottM8 wrote:
I'm very sorry...I tried to follow the instructions to turn the SAS data in to a data step, but was unsuccessful. Here is an example of a response, the response crosswalk, and the desired outcome
Survey Response Data
ClientID
Question
Answer
1
11. In the past year, how many times have you been to the emergency room?
Twice
Survey Crosswalk
Question
Response
Need
Problem
Goal
11. In the past year, how many times have you been to the emergency room?
Once
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. In the past year, how many times have you been to the emergency room?
Twice
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. In the past year, how many times have you been to the emergency room?
Three or more
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.
Desired Outcome:
ClientID
Question
Answer
Need
Problem
Goal
1
11. In the past year, how many times have you been to the emergency room?
Twice
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.
Do you have an example of one or two of these where 1) the Need Changes and/or 2) the Goal Changes?
And is the "Need" common to other questions?
If the Need does not change then "Problem" is quite doable with a format.
If the Goal does not change then either a format may well be workable as well.
Does you question 11 have any response choice of Zero or None? Is that all of the possible responses to question?
A slightly more targeted format and label approach.
proc format library=work;
value $q11_P
"Once" = "Emergency Room Visits - One visit reported"
"Twice" = "Emergency Room Visits - Two visits reported"
"Three or more"= "Emergency Room Visits - Three or more visits reported"
"None" = " "
;
value $q11_G
"Once",
"Twice",
"Three or more"= "Have 0 ER visits over next 60 days. See your doctor or urgent care facility when appropriate."
"None" = " "
;
run;
data have;
infile datalines dlm=',';
input clientid $ q11 $15.;
label
clientid ="Client Identifier"
Q11= "In the past year, how many times have you been to the emergency room?"
;
datalines;
1,Once
2,Twice
3,Three or more
4,None
;
proc print data=have noobs label;
title "Q11 values printed with Problem format";
format q11 $q11_p.;
run; title;
proc print data=have noobs label;
title "Q11 values printed with Goal format";
format q11 $q11_G.;
run; title;
I am afraid that to get output that looks exactly like your desired outcome is very dependent on your actual data structure and content and without a good example I'm not sure what to suggest.
I will say that if I have a document like your crosswalk then it is not difficult in Excel to create the Format statements similar to what I show. And if the document is well structured creating a variable label statement is not much work either.
If you can't turn the SAS data set, or part of it into data step code can you copy some lines of the data from your data source and paste that as text? Change anything sensitive like client identity information to some that can't link back to your actual data.
Copy the data lines, including a header row if any, into a text box opened with the forums {I}.
I can say from working with survey data for more than 20 years I have yet to have a software package output the responses with question identity and value one the same row aw your "response data" implies.
... View more