Can some one help me with a syntax to transpose from long to wide by two variables.
I have following dataset (example):
ID Matnr Code
19 1 P200
19 1 T500
19 1 M870
19 2 P400
19 2 M871
20 1 P400
20 1 M871
20 2 P200
20 2 T800
20 2 T812
20 2 M871
I would like it to be transposed by ID and Matnr. like:
ID Matnr Code_1 Code_2 Code_3 Code_4
19 1 P200 T500 M870
19 2 P400 M871
20 1 P400 M871
20 2 P200 T800 T812 M871
If your data is sorted correctly you should be fine with
Proc sort data=source out=transposed
prefix=Code_
;
by id matnr;
var code;
run;
If your data is sorted correctly you should be fine with
Proc sort data=source out=transposed
prefix=Code_
;
by id matnr;
var code;
run;
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.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.