BookmarkSubscribeRSS Feed
Ronein
Onyx | Level 15

Hello

What is the way to create "want" data set from "Have data set"?

(Long to wide)

Data have;
input Key CustomerID seq;
cards;
111 2345677 1
111 4356674 2
111 3467886 3
444 4456567 1
444 8837737 2
222 5575775 1
;
Run;

Data want;
input key  CustomerID1 CustomerID2 CustomerID3;
cards;
111 2345677 4356674 3467886
444 4456567 8837737 .
222 5575775 . .
;
Run;
5 REPLIES 5
andreas_lds
Jade | Level 19

Ok, Ronin this is the nth time you ask for transposing data, so: what have you tried? What is the problem?

Oligolas
Barite | Level 11

😁

Fill in the blanks:

PROC ____ data=____;by ___ ___; RUN;
PROC _________ data=____ out=_____(drop=______) prefix=__________;
   by ___;
   var __________;
   id ___;
RUN;

PROC SORT data=have;by key seq; RUN;
PROC TRANSPOSE data=have out=trans(drop=_name_) prefix=CustomerID;
by key;
var customerID;
id seq;
RUN;

________________________

- Cheers -

Reeza
Super User

If you don't want to learn how to code use the Tasks, point and click, which guide you through the process. 

 

https://documentation.sas.com/doc/en/webeditorcdc/v_003/webeditorref/n0an4t2gh0zmb3n13i9afkc7xqao.ht...

 


@Ronein wrote:

Hello

What is the way to create "want" data set from "Have data set"?

(Long to wide)

Data have;
input Key CustomerID seq;
cards;
111 2345677 1
111 4356674 2
111 3467886 3
444 4456567 1
444 8837737 2
222 5575775 1
;
Run;

Data want;
input key  CustomerID1 CustomerID2 CustomerID3;
cards;
111 2345677 4356674 3467886
444 4456567 8837737 .
222 5575775 . .
;
Run;

 

 

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1547 views
  • 2 likes
  • 5 in conversation