BookmarkSubscribeRSS Feed
Ronein
Meteorite | Level 14

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;

 

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

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
  • 5 replies
  • 490 views
  • 2 likes
  • 5 in conversation