BookmarkSubscribeRSS Feed
podarum
Quartz | Level 8

Is there a way i can create multiple rows into 1 columns ?... example below:

HAVE:

Date 1        City1       City2    City3
2012.01       4              5         8

2012.02      12            10        5 

2012.03       5              3         1 

2012.04       9             2          1

WANT:

Date1        Rate       City

2012.01      4            City1

2012.02      12          City1

2012.03       5           City1

2012.04       9           City1

2012.01      5            City2

2012.02      10          City2

2012.03       3           City2

2012.04       2           City2

2012.01      8            City3

2012.02      5           City3

2012.03      1           City3

2012.04       1           City3

Thanks

2 REPLIES 2
art297
Opal | Level 21

You could use proc transpose.  One way would be:

proc transpose data=have out=want

  (rename=(_name_=city col1=rate));

  var city1-city3;

  by date1;

run;

Jagadishkatam
Amethyst | Level 16

Alternatively by arrays,

data want;

    set have;

    array cits(3)$ ("city1" "city2" "city3");

    array cit(3) city1-city3;

    do i = 1 to 3;

    city=cits(i);

    rate=cit(i);

    output;

    end;

    keep date rate city;

run;

Thanks,

Jagadish

Thanks,
Jag

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!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 686 views
  • 6 likes
  • 3 in conversation