Date: Wed, 28 Jan 2009 11:23:11 +0000
Reply-To: karma <dorjetarap@GOOGLEMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: karma <dorjetarap@GOOGLEMAIL.COM>
Subject: Re: Proc Transpose
In-Reply-To: <200901271554.n0RBqc59018751@malibu.cc.uga.edu>
Content-Type: text/plain; charset=ISO-8859-1
Yet Another Way
Using a DOW and a few retains
data have;
input CONT_ID PRSNL_T :$10. NBR_PRSN ;
cards;
000902050 SKILLED 20
000902050 SKILLED 12
000902050 SUPERVISOR 10
000902050 SUPERVISOR 1
000902050 UNSKILLED 49
000902050 UNSKILLED 30
;
proc sql noprint;
select unique prsnl_t
into :names separated by ' '
from have order by prsnl_t;
quit;
%put &names;
data want(keep=cont_id &names total);
retain cont_id &names total;
array names[*] &names;
do until (last.prsnl_t);
set have;
by cont_id prsnl_t;
x=sum(0,x,nbr_prsn);
end;
names[_n_] = x;
total = sum(0, total, x);
if last.cont_id;
run;
proc print;run;
2009/1/27 Paul St Louis <pstloui@dot.state.tx.us>:
> Have:
> CONT_ID PRSNL_T NBR_PRSN
> 000902050 SKILLED 20
> 000902050 SKILLED 12
> 000902050 SUPERVISOR 10
> 000902050 SUPERVISOR 1
> 000902050 UNSKILLED 49
> 000902050 UNSKILLED 30
>
> Need:
> CONT_ID SKILLED UNSKILLED SUPERVISOR TOTAL
> 000902050 32 79 11 122
>
> I'm stumped on Proc Transpose, and can't figure out how to get the results.
> I can split up my dataset into skilled, supervisor, unskilled, them proc
> summ, but there must be a better way.
>
|