BookmarkSubscribeRSS Feed

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;
Var bal_sasout;
table (prod_class="" all="TOTAL TOTAL") ,
(curr_ind_ltv="" all="Bottom Total") *
(acc_status_1="") *
(start_date="") ,
(sum="£££"*f=comma19. rowpctsum="%" n="#" min max mean std) *
(region="" all="Right Total") *
(bal_sasout="") /box=_page_;
format region $region. curr_ind_ltv ltv_band. prod_class $pclass. start_date sdates.;


Thanks in advance

Opal | Level 21

Here's a good starting point to begin your studies:





  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:




Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Get the $99 certification deal.jpg



Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 3 in conversation