change format of dataset

Reply
N/A
Posts: 1

change format of dataset

I have sales data in this format:

Year    Chicago     LosAngeles     NewYork ...........

1995     10                20                  15

1996      20               34                  45

1997      34                22                12

1998      22               23                  43

I want to convert this in this format.

Year    City           Sales

1995   Chicago      10

1995   LosAngeles  20

1995   NewYork     15

1996   Chicago       20

1996   LosdAngeles 34

1996  NewYork      45

How do I do this?

Trusted Advisor
Posts: 1,228

Re: change format of dataset

Posted in reply to roshnikumar

data have;

input Year    Chicago     LosAngeles     NewYork;

datalines;

1995     10               20                15

1996     20               34                45

1997     34               22                12

1998     22               23                43

;

proc transpose data=have out=want(rename=(col1=sales _name_=city));

by year;

run;

Ask a Question
Discussion stats
  • 1 reply
  • 142 views
  • 0 likes
  • 2 in conversation