[SAS base] Proc report

Source: Internet
Author: User

Proc report includes the print, means, tabulate, sort process, and data step functions:

I. Basic Syntax:

1 Data natparks; 2 infile 'C: \ myrawdata \ parks. dat '; 3 input name $1-21 type $ region $ museums camping; 4 run; 5 6/* ----- group and analyze SS variables (group: vertical; horizontal SS: horizontal) --- */7 * region as group and type as variant SS variable with sums; 8 proc report data = natparks nowindows headline; 9 column region type N, (museums camping), mean; 10/* add statistics to the report: you only need to add the statistics to the column statement variables and separate them with commas. N is not required in particular. If n is inserted in the column statement, the observed number of rows in the report is calculated */11 define region/group; 12 define type/ignore SS; 13 title '... '; 14 run;

 

Note:

1. Proc report:

Nowindows: do not enable interatctive report winow for the SAS command. Headline: If the headline option is not available, SAS will list the specific data directly under the column name, while the headline option command SAS unified a line under the column name and then input data; headskip: Used in the same way as headline, the command SAS unified a blank line under the column name and then input data


2. colunm statement: similar to VaR in the proc print statement, it tells SAS which variables need to be output in what order. If this parameter is omitted, all outputs are made.
3. Define statement: specify the specific options for the variable.

1 Define variable/options 'column-header'; 2 example: 3 define age/order' age at/admission 'width = 9;/* Where,/is a line feed, the admission width is 9 */

Options:

1. compute SS: Creates a column for each unique value of the variable. 2. Analysis: calculates the statistic for the variable. The default value is a numeric variable. The statistic is the sum by default. 3. computed: create a new variable for the value of calculate in a compute block; 4 display: Creates a row for each new observation in the dataset. The default value is the week type; 5 group: create a row for each unique value of the variable; 6 Order: Create a row for each observed value of the variable.

 

 

Note:

1. If only numeric variables exist in the data, the proc report automatically outputs only the sum of these variables by default. If the data contains complex variables, the proc report outputs a detailed report for each observation;

 

Ii. Add summary breaks to proc report output

1 break location variable/options; 2/* Add a break to the location of each unique value of variable, the variables in the break statement must be defined in the define statement */3 rbreak location/options; 4/* Add a break to the location of the report, therefore, you do not need to specify variable */5 6 [Location Value]: Before or after; 7 [Options Value]: 8 1. ol/ul: draw a line above/below break; 9 2. page: start a new page; 10 3. SKIP: Insert a blank line11 4. summarize: inserts the sum of numeric variables.

 

3.Add computed variable to proc report output)

1 Data natparks; 2 infile 'C: \ myrawdata \ parks. dat '; 3 input name $1-21 type $ region $ museums camping; run; 4 5 * compute new variables that are numeric and character; 6 proc report data = natparks nowindows headline; 7 column name region museums camping facilities note; 8 define museums/analysis sum noprint; 9 define camping/analysis sum noprint; 10 define camping/computed 'camping/AND/Museum '; 11 define note/computed; 12 compute facilities;/* computing numeric variable */13 facilities = museums. sum + camping. SUM;/* append the statistic to the variable name in the form of a suffix */14 endcomp; 15 compute note/Char length = 10;/* computing fixed variable, add the char option after compute. The default length = option is 8 */16 if camping. sum = 0 then note = 'no camping'; 17 endcomp; 18 title 'report with two computed variables '; 19 run;

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.