Created
June 11, 2018 23:59
-
-
Save statgeek/1c6f38ef368a4272cf458b017fc63d4b to your computer and use it in GitHub Desktop.
SAS - formats - multilabel formats
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 shows how an multilabel format works and that the summary statistics can be done at a unique level but also aggregated at a higher level included in the data.*/ | |
/*sample data*/ | |
data have; | |
input Year Area $ Profit; | |
cards; | |
2001 A 1 | |
2002 A 2 | |
2001 B 1 | |
2001 C 3 | |
2002 C 1 | |
2001 E 4 | |
2002 E 2 | |
2001 F 3 | |
2002 F 4 | |
;;;; | |
run; | |
*format - groups A/B/C into D and E/F into G as well; | |
proc format; | |
value $ area_fmt (multilabel) | |
'A' = 'A' | |
'B' = 'B' | |
'C' = 'C' | |
'A', 'B', 'C' = 'D' | |
'E' = 'E' | |
'F' = 'F' | |
'E', 'F' = 'G'; | |
run; | |
*summary statistics - not CLASS and FORMAT statements; | |
proc means data=have noprint nway; | |
class year area / mlf; | |
format area $area_fmt.; | |
var profit; | |
output out=want sum(profit)=profit; | |
run; | |
*show results; | |
proc print data=want; | |
run; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment