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-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 597 views
  • 3 likes
  • 2 in conversation