BookmarkSubscribeRSS Feed
sasusername
Calcite | Level 5

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

2 REPLIES 2
Linlin
Lapis Lazuli | Level 10

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=_:) 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

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Health and Life Sciences Learning

 

Need courses to help you with SAS Life Sciences Analytics Framework, SAS Health Cohort Builder, or other topics? Check out the Health and Life Sciences learning path for all of the offerings.

LEARN MORE

Discussion stats
  • 2 replies
  • 1170 views
  • 0 likes
  • 2 in conversation