[SAS base] Proc tabulate (outputs more exquisite tabulate reports)

Source: Internet
Author: User
Tags proc tabulate

The general form of Proc tabulate: (the subject is different from the freq process. Here is the table statement, not tables)

1 proc tabulate format = options;/* format = option to change the format of all cells in the table */2 var analysis-variable-list; 3 class classification-variable-list; /* the variables in the following Table statement must appear in the VaR statement or class in advance */4 Table Page-dimension, row-dimension, column-dimension/box = option misstext = option; 5/* box = option specifies the sentence in the space in the upper left corner of the output tabulate report; misstext = the option assigns a specific value to the empty data cells */6 run;

Note:

  1. VaR statement: In addition to listing variable names, the VaR statement can also contain statistics, such as: All (sum in this dimension), Max, Min, mean, median, mode, n, nmiss, pctn, pctsum, stddev, Sum.
  2. TABLE statement of the same latitude variable concateting, crossing, and grouping:
    1 concatenating: simply list them separated by a space; 2 crossing: List variables or keywords separated by an *; 3 grouping: List variables or keywords in parentheses
     1.keyword ALL is generally concatenated; 2. To request other statistics, cross the keyword with the variable name.

Example:

1 Data boats; 2 infile 'C: \ myrawdata \ boat. dat '; 3 input name $1-12 port $14-20 locomotion $22-26 type $28-30 price 32-36; 4 run; 5 * Changing headers; 6 proc format;/* if you want to change the title of the class variable value, Step 1: use this format statement to define the new format */7 value $ typ 'cat' = 'catamaran '8' Sch '= 'shanghai' 9 'yac' = 'yacht'; 10 run; 11 12 proc tabulate data = boats format = dollar9.2; 13 class locomotion type; 14 var price; 15 format type $ typ .; 16 Table locomotion = ''all,/* change the variable title */17 mean = ''' * price = 'mean price by type of Boat' * (type = ''all) /box = 'full day excursions 'misstext = 'none';/* change the keyword title */18 title; 19 run;

Note:

  • Change the title of the output table of Proc tabulate
  1. Title formed by changing the classification value of the class variable: defines a new format through this format, and then assigns a value to this classification variable through the format statement;
  2. Change the title of a variable or Keyword: connect the variable or keyword with the new title equal sign enclosed in single quotes. In particular, if the variable is '', the title is deleted.

  • Specify different results for each cell: add the format = option after proc format to make the format of all cells in the table the same. If different cells have different formats, to apply a format to an individual variable, cross it with the variable name ). for example:
    1 TABLE Region, Mean*(Sales*FORMAT=COMMA 8.02                     Profit*FORMAT=DOLLAR10.2);

     

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.