Skip to content

Instantly share code, notes, and snippets.

@queirozfcom
Created February 23, 2018 02:55
Show Gist options
  • Save queirozfcom/683ac1051411533ab32ba258aa29e947 to your computer and use it in GitHub Desktop.
Save queirozfcom/683ac1051411533ab32ba258aa29e947 to your computer and use it in GitHub Desktop.
data mytable;
input id= name=$12. balance= state=$2.;
DATALINES;
id=1 name=alice balance=5.12 state=NE
id=2 name=bob balance=12.31 state=SC
id=3 name=charlie balance=45.14 state=NY
id=4 name=daniel balance=32.78 state=
id=5 name=alice balance=20.23 state=WA
id=6 name=bob balance=70.89 state=NM
id=7 name=gabe balance=29.67 state=NM
id=8 name=charlie balance=55.66 state=CA
id=9 name=ivan balance= state=
;
run;
proc freq data=mytable;
tables state;
run;
proc freq data=mytable;
tables state / missing;
run;
ods graphics on;
proc freq data=mytable;
tables state / plots=freqplot();
run;
proc format;
value balance_bins
0 = "Exactly 0"
0 -< 10 = "Up to US$ 10"
10 -< 20 = "From US$ 10 to US$ 20"
20 -< 30 = "From US$ 20 to US$ 30"
30 -< 40 = "From US$ 30 to US$ 40"
40 -< 50 = "From US$ 40 to US$ 50"
50 - high = "Above US$ 50"
. = "No data"
other = "???";
run;
ods graphics on;
proc freq data=mytable;
tables balance/ missing plots=freqplot;
format balance balance_bins.;
run;
ods graphics on;
proc freq data=mytable;
tables state*name / plots=freqplot(groupby=row twoway=stacked);
run;
ods graphics on;
proc freq data=mytable;
tables state*balance / plots=freqplot(groupby=row twoway=stacked);
format balance balance_bins.;
run;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment