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;
Ok, Ronin this is the nth time you ask for transposing data, so: what have you tried? What is the problem?
PROC TRANSPOSE with PREFIX option and seq as ID. Unless you sort first, you'll need a NOTSORTED option in the BY.
😁
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 -
If you don't want to learn how to code use the Tasks, point and click, which guide you through the process.
@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 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.