BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Haydn
Quartz | Level 8

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

1 ACCEPTED SOLUTION

Accepted Solutions
RahulG
Barite | Level 11

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;

 

View solution in original post

2 REPLIES 2
RahulG
Barite | Level 11

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;

 

Reeza
Super User

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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 2554 views
  • 1 like
  • 3 in conversation