reformatting data from rows to columns.....

  • Follow


hi, ive created a SAS data set that contains the following
variables...

week	name	Task	day_of_week	sum_hours
45	John Smith	Adhoc Data Requests	Friday	1.5
45	John Smith	Adhoc Data Requests	Monday	4.5
45	John Smith	Adhoc Data Requests	Thursday	0.5
45	John Smith	Adhoc Data Requests	Tuesday	1
46	John Smith	Investigations/Data Discrepancies	Monday	0.25
46	John Smith	Investigations/Data Discrepancies	Thursday	0.25

what i need to do i output the file in excel format, but with the
'day_of_week' displayed as columns rather than rows. I can do this
easily using pivot tables in excel, but wondered if its possible in
SAS? I need the output to look like below (slight problem when pasting
into this email, but can email attachment if needed)....

			day_of_week
week	name	Task	Monday	Tuesday	Thursday	Friday
45	John Smith	Adhoc Data Requests	4.5	1	0.5	1.5
46	John Smith	Investigations/Data Discrepancies	0.25		0.25


Many thanks for all your help

Cheers, Wes

0
Reply w.greenhead (12) 11/27/2009 2:34:36 PM

You just simply employ the proc transpose.


data test;
input week 1-2 name $ 4-13 task $ 15-47 day_of_week $ 49-56 sum_hours
58-61;
datalines;
45 John Smith Adhoc Data Requests               Friday   1.5
45 John Smith Adhoc Data Requests               Monday   4.5
45 John Smith Adhoc Data Requests               Thursday 0.5
45 John Smith Adhoc Data Requests               Tuesday  1
46 John Smith Investigations/Data Discrepancies Monday   0.25
46 John Smith Investigations/Data Discrepancies Thursday 0.25
;
run;

proc transpose data=test out=outset(drop=_NAME_);
	by week name task;
	id day_of_week;
	var sum_hours;
run;
0
Reply zhang3stone 11/27/2009 3:21:34 PM


Brilliant!! Thank you very much! Thats solved the problem

Cheers, Wes
0
Reply wes 11/27/2009 3:45:27 PM

2 Replies
308 Views

(page loaded in 0.074 seconds)

Similiar Articles:













7/24/2012 12:46:59 AM


Reply: