Help using Base SAS procedures

how to stack variables in different columns?

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 7
Accepted Solution

how to stack variables in different columns?

I have a data table that consists of customers  ID's and their telephone numbers in the following manner:

Customer IDtelephone number

5550

9613456789
55509613657894
67589611567854

Which function enables me to have the following format :

Customer IDtelephone number 1telephone number 2
555096134567899613657894
67589611567854.

Thank you in advance for all your help


Accepted Solutions
Solution
‎10-13-2014 06:28 AM
Super Contributor
Posts: 305

Re: how to stack variables in different columns?

Hello,

data have;
input Customer_ID  telephone_number $;
datalines;
5550 9613456789
5550 9613657894
6758 9611567854
;

proc transpose data=have out=want(drop=_name_) prefix=Telephone;
by Customer_ID;
var telephone_number;
run;

View solution in original post


All Replies
Regular Contributor
Posts: 168

Re: how to stack variables in different columns?

Have a look at proc transpose.

Solution
‎10-13-2014 06:28 AM
Super Contributor
Posts: 305

Re: how to stack variables in different columns?

Hello,

data have;
input Customer_ID  telephone_number $;
datalines;
5550 9613456789
5550 9613657894
6758 9611567854
;

proc transpose data=have out=want(drop=_name_) prefix=Telephone;
by Customer_ID;
var telephone_number;
run;

Occasional Contributor
Posts: 7

Re: how to stack variables in different columns?

Thank you that was very helpfull

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 228 views
  • 3 likes
  • 3 in conversation