New user - Help with changing column values into row values

Reply
New Contributor
Posts: 2

New user - Help with changing column values into row values

Hi All,

I'm trying to create a product information table and would like to create a flat file of our supplies by distributors. There is a maximum of three suppliers per part number. Here is how our data is structured and what I want to do..

Part# 1Manuf 1Supplier 1
Part# 1Manuf 1Supplier 2
Part# 1Manuf 1Supplier 3
Part# 2Manuf 2Supplier 4
Part# 2Manuf 2Supplier 5
Part# 3Manuf 3Supplier 6

TO..

Part# 1Manuf 1Supp1Supp2Supp3
Part# 2Manuf 2Supp4Supp5Blank
Part# 3Manuf 3Supp6BlankBlank

I just started using SAS and I'm slowly learning the code. Is this possible in SAS?

Thanks for your help

- J

Super Contributor
Posts: 1,636

Re: New user - Help with changing column values into row values

using proc transpose:

data have;

  input (p m s)($);

  cards;

p1 m1 s1

p1 m1 s2

p1 m1 s3

p2 m2 s4

p2 m2 s5

p3 m3 s6

;

proc transpose data=have out=want(drop=_Smiley Happy prefix=s;

by p m;

var s;

run;

proc print;run;

                        Obs    p     m     s1    s2    s3

                          1     p1    m1    s1    s2    s3

                          2     p2    m2    s4    s5

                          3     p3    m3    s6

New Contributor
Posts: 2

Re: New user - Help with changing column values into row values

Thanks.

Post a Question
Discussion Stats
  • 2 replies
  • 402 views
  • 0 likes
  • 2 in conversation