Hi,
I have a data set called "Complaints". In this dataset are columns called "Ref" and "Reason".
The "Ref" is a customers reference number. For each reference number there is a "Reason". This dataset can and does contain duplicate reference numbers.
Is there a way that I can create a new dataset and have disctinct "Ref" and create new columns for each "Reason"? Some customers can have 20 different "Reason"s.
Cheers
Haydn
Hi
Hope I understood your problem correctly. Below I tried to solve it using proc transpose.
See if this work, otherwise provide more information on how your input data looks like.
data complaints;
input customer $ ref reason $20.;
datalines;
C1 101 Not happy
C1 101 Delayed Service
C1 102 High Price
C2 101 Not happy
C2 101 Delayed Service
C2 101 Prolong resolution
;
run;
proc transpose data=complaints out=transposed;
by customer ref;
var reason;
run;
Hi
Hope I understood your problem correctly. Below I tried to solve it using proc transpose.
See if this work, otherwise provide more information on how your input data looks like.
data complaints;
input customer $ ref reason $20.;
datalines;
C1 101 Not happy
C1 101 Delayed Service
C1 102 High Price
C2 101 Not happy
C2 101 Delayed Service
C2 101 Prolong resolution
;
run;
proc transpose data=complaints out=transposed;
by customer ref;
var reason;
run;
The second part of your question is commonly known as a transpose.
You should find an option under Data Tasks to transpose the data.
But given your description it sounds like you may need to split your file one for REF and one for Reason? Otherwise how do you want it to look, will all the reason variables be empt for the REF records? This is a case where you need to provide sample input and output data.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.