SAS: Replicate PROC MEANS output in PROC TABULATE -
i replicate output of proc means using proc tabulate. reason have profit percentage (or margin) 1 of variables in proc means output, suppress calculation 1 or more of statistics i.e. there '-' or similar in 'margin' row under 'n' , 'sum.
here sample data:
data have; input username $ betdate : datetime. stake winnings; dateonly = datepart(betdate) ; format betdate datetime.; format dateonly ddmmyy8.; datalines; player1 12nov2008:12:04:01 90 -90 player1 04nov2008:09:03:44 100 40 player2 07nov2008:14:03:33 120 -120 player1 05nov2008:09:00:00 50 15 player1 05nov2008:09:05:00 30 5 player1 05nov2008:09:00:05 20 10 player2 09nov2008:10:05:10 10 -10 player2 15nov2008:15:05:33 35 -35 player1 15nov2008:15:05:33 35 15 player1 15nov2008:15:05:33 35 15 run; data want; set have; retain margin; margin = (winnings) / stake; proc print; run;
i have been calculating statistics proc means (like below), value sum statistics 'margin' variable means nothing: suppress value. have therefore been attempting replicate table using proc tabulate have more control of output, have been unsuccessful far.
proc means data=want n sum mean median stddev min max maxdec=2 order=freq stackods; var stake winnings margin; run; proc tabulate data=want; var stake winnings margin; table stake * (n sum mean median stddev min max); run;
i appreciate on this.
in principle, can't create type of output default part of tabulate function; in essence, asking 2 different table definitions. sas syntax amount adding more dimensions table, won't fix core problem.
you can use code tables want, they're still different tables:
proc tabulate data=want noseps; var stake winnings margin; table (stake winnings),(n sum mean median stddev min max); table (margin),(n mean median stddev min max); run;
there guides out there on hacking ods want (namely, create "stacked tables" several child tables assembled single table. check out here example. if google "sas stack tables" you'll find more examples.
i've done in html creating new tagset - basically, special ods destination removes spaces between tables, etc. don't have code used anymore, unfortunately; moved r automated reporting.
Comments
Post a Comment