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;
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.