08-11-2016 08:50 AM
Hi, I am new to SAS Syntax. Would someone mind please explaing row by row what this code is doing as this would benefit me in understanding it?
proc tabulate data = mortbib.mortgagebible_201606 missing;
class acc_status_1 start_date prod_class region curr_ind_ltv /preloadfmt order=data mlf;
table (prod_class="" all="TOTAL TOTAL") ,
(curr_ind_ltv="" all="Bottom Total") *
(sum="£££"*f=comma19. rowpctsum="%" n="#" min max mean std) *
(region="" all="Right Total") *
format region $region. curr_ind_ltv ltv_band. prod_class $pclass. start_date sdates.;
Thanks in advance
08-11-2016 09:14 PM
You are the only one, with the data and the user defined formats. No one can run this program without making both the data AND the formats. In addition, the program is using PRELOADFMT and multi-label formats (MLF), which are more advanced uses of formats with PROC TABULATE.
In brief, the CLASS statement is "declaring" which variables will be used to set categories for grouping; the VAR statement is "declaring" which variable will be used for analysis and then the TABLE statement is specifying what the table structure of the report table will look like. The FORMAT statement is using formats to further format several of the variables for output, without seeing the formats, it is hard to explain what the formats are doing, since PRELOADFMT and MLF is specified for ALL the CLASS variables, to explain the format, someone would have to see the PROC FORMAT code and the data to explain what that was doing.
PROC TABULATE follows very strict rules for structure:
TABLE xxxxx; (no commas = column dimension)
TABLE yyyy,xxxxx; (1 comma = yyyy in row dimension and xxxxx in column dimension)
TABLE zzzz, yyyy, xxxxx; (2 commas = zzzz in page dimension, yyyy in row dimension, xxxxx in column dimension) .
But where I have ZZZZ and YYYY and XXXXX, you could have variables, keyword statistics and table operators and the ALL "summary" variable. So the bottom line is that you almost need to "deconstruct" the PROC TABULATE syntax and simplify it.
Something like this -- a much simplified version of your table showing the relationship between the dimensions: