Date: Sun, 7 Dec 2008 21:40:41 -0600
Reply-To: sas 9 bi user <sas9bi@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: sas 9 bi user <sas9bi@GMAIL.COM>
Subject: Transform wide to long
Content-Type: text/plain; charset=ISO-8859-1
/*
Friends,
I have been so stuck trying to do this wide to long dataset conversion.
These arrays just throw me for a loop (pun intended). I have spent the last
40 mins trying to get this to work and thought I would just post my question
as one of you could solve in about 1 minute.
Below is what I have and what I want. Note my "Want" data set is incomplete
but you should get the gist of what I am looking for.
Thanks in advance for any thoughts!!
*/
DATA have;
input product $ date mmddyy11. Atlanta_store Chicago_store Seattle_store
San_Francisco_store;
CARDS;
Beans 01/01/2007 10.4 11.4 43.3 44.2
Beans 02/01/2007 11.4 16.4 63.3 74.2
Beans 03/01/2007 12.4 13.4 23.3 34.2
Beans 04/01/2007 13.4 15.4 53.3 84.2
Beans 05/01/2007 15.4 14.4 23.3 64.2
Milk 01/01/2007 10.4 11.4 43.3 44.2
Milk 02/01/2007 11.4 16.4 63.3 74.2
Milk 03/01/2007 12.4 13.4 23.3 34.2
Milk 04/01/2007 13.4 15.4 53.3 84.2
Milk 05/01/2007 15.4 14.4 23.3 64.2
;
RUN;
DATA want;
input product $ date mmddyy11. store $ value;
CARDS;
Beans 01/01/2007 Atlanta_store 10.4
Beans 02/01/2007 Atlanta_store 11.4
Beans 03/01/2007 Atlanta_store 12.4
Beans 04/01/2007 Atlanta_store 13.4
Beans 05/01/2007 Atlanta_store 15.4
Beans 01/01/2007 Chicago_store 11.4
Beans 02/01/2007 Chicago_store 16.4
Beans 03/01/2007 Chicago_store 13.4
Beans 04/01/2007 Chicago_store 15.4
Beans 05/01/2007 Chicago_store 14.4
Milk 01/01/2007 Atlanta_store 10.4
Milk 02/01/2007 Atlanta_store 11.4
Milk 03/01/2007 Atlanta_store 12.4
Milk 04/01/2007 Atlanta_store 13.4
Milk 05/01/2007 Atlanta_store 15.4
;
RUN;