SQL can give you less code and faster speed . I am about to make a paper about this when you are building a report .
data office;
infile cards expandtabs;
input (ID RACE GENDER PMT_TYPE ICD VISIT OFFICE)($);
cards;
AA H M HMO 290 IN 9
AB H M HMO 290 OUT 9
AC H M FFS 290 IN 9
AD H M MC 290 IN 9
BA H F HMO 290 OUT 9
BB H F FFS 290 IN 9
BC H F PPO 290 IN 9
BD H F MC 290 IN 9
CA W M HMO 290 OUT 9
CB W M FFS 290 IN 9
CC W M PPO 290 IN 9
CD W M MC 290 OUT 9
CD W M MC 290 OUT 9
DA W F HMO 290 OUT 9
DB W F FFS 290 IN 9
DC W F PPO 290 OUT 9
DD W F MC 290 OUT 9
ZA H M HMO 290 IN 8
ZB W F HMO 290 IN 8
ZC W F HMO 290 OUT 8
;;;;
run;
proc sql;
create table temp as
select office,race,gender,PMT_TYPE as type ,count(*) as n
from office
group by office,race,gender,PMT_TYPE
union
select office,race,gender,ICD as type ,count(*) as n
from office
group by office,race,gender,ICD
union
select office,race,gender,VISIT as type ,count(*) as n
from office
group by office,race,gender,VISIT ;
quit;
proc transpose data=temp out=temp1(drop=_:);
by office race gender ;
id type;
var n;
run;
proc stdize data=temp1 out=want missing=0 reponly;run;
Xia Keshan
... View more