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

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

New Learning Events in April

 

Join us for two new fee-based courses: Administrative Healthcare Data and SAS via Live Web Monday-Thursday, April 24-27 from 1:00 to 4:30 PM ET each day. And Administrative Healthcare Data and SAS: Hands-On Programming Workshop via Live Web on Friday, April 28 from 9:00 AM to 5:00 PM ET.

LEARN MORE

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