Created
February 28, 2018 16:58
-
-
Save statgeek/0c4aeec9053cf8050be18a03b842c1b9 to your computer and use it in GitHub Desktop.
PROC FREQ - Cross Tab Table in a long format
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*This program is used when you want multiple m*n tables and you want it summarized. In this case the one variable, SEX is in the | |
KEEP statement, this will change depending on the variables in the code*/ | |
ods output crosstabfreqs=summary; | |
proc freq data=sashelp.class; | |
table sex*(_all_); | |
run; | |
data long; | |
length variable $32. variable_value $50.; | |
set summary; | |
Variable=scan(table, 2, '*'); | |
Variable_Value=strip(trim(vvaluex(variable))); | |
presentation=catt(frequency, " (", trim(put(percent/100, percent7.1)), ")"); | |
keep sex variable variable_value frequency percent presentation; | |
label variable='Variable' variable_value='Variable Value'; | |
run; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment