Skip to content

Instantly share code, notes, and snippets.

@rpardee
Created June 30, 2015 22:02
Show Gist options
  • Save rpardee/d10d9774b9314918c718 to your computer and use it in GitHub Desktop.
Save rpardee/d10d9774b9314918c718 to your computer and use it in GitHub Desktop.
proc format ;
value $sx
"F" = "Girls"
"M" = "Boys"
;
value ag
low - 12 = '12 and under'
13 - high = '13 and up'
;
quit ;
%let out_folder = c:/deleteme ;
data shill ;
length sex $ 5 ;
set sashelp.class ;
do teacher = 'Mr. Smith', 'Ms. Jones' ;
if teacher = 'Ms. Jones' then age = age - 1 ;
output ;
end ;
run ;
ods html path = "&out_folder" (URL=NONE)
body = "tab_sketch.html"
(title = "tab_sketch output")
;
* rowpctn gives the percentages across the whole row--how do I get percentages within sex? ;
* e.g., what perceentage of the girls in Mr. Smith's class are 12 or younger? ;
proc tabulate data = shill ;
class teacher sex age ;
keylabel N = " " sum = " " ;
var height weight ;
table teacher, sex=" " * age=" " * (n="N" rowpctn="%") ;
format sex $sx. age ag. ;
run ;
ods _all_ close ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment