BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
MABRINCH
Fluorite | Level 6

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          

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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;

View solution in original post

1 REPLY 1
ballardw
Super User

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;

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!

What is Bayesian Analysis?

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.

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
  • 1 reply
  • 332 views
  • 3 likes
  • 2 in conversation