SAS_BASE_4_final.docx - TOPIC4 Generating Reports 1...

This preview shows page 1 - 6 out of 34 pages.

TOPIC4 Generating Reports 1. Generating list reports .................................................................................................................. 2 1.1 PRINT procedure ................................................................................................................... 2 1.2 REPORT procedure ............................................................................................................... 9 1.3 MEAN procedure ................................................................................................................. 16 1.4 PROC FREQ procedure ....................................................................................................... 23 2. Generate reports using ODS statements .................................................................................... 31 2.1 What is ODS ........................................................................................................................ 31 2.2 Destinations ......................................................................................................................... 31 2.3 Sending SAS Output to an HTML File ............................................................................... 31 1
Image of page 1

Subscribe to view the full document.

1. Generating list reports 1.1 PRINT procedure Syntax: PROC PRINT <option(s)>; BY <DESCENDING> variable-1 <...<DESCENDING> variable-n> PAGEBY BY-variable; SUMBY BY-variable; ID variable(s) <option>; SUM variable(s) <option>; VAR variable(s) <option>; Example 1: print all variables and observations /*print all observations and variables, and variables appear in the order in which they occur in the data set*/ Data prin1; Input points grade lname $ fname $ gender $; datalines ; 100 3 Griffin Angela F 200 3 James Ellen F 400 4 Peeler Lane M 600 6 Whitlock Nancy F 700 4 Jenny Liu M ; Run ; proc print data =prin1; Run ; Example 2: Selecting Variables to Print /* using a VAR statement in your PROC PRINT step to control variables and order*/ Data prin1_1; Input points grade lname $ fname $ gender $; datalines ; 100 3 Griffin Angela F 200 3 James Ellen F 400 4 Peeler Lane M 2
Image of page 2
600 6 Whitlock Nancy F 700 4 Jenny Liu M ; Run ; proc print data =prin1_1; var points lname gender; Run ; Example 3: Removing the OBS Column and replace OBS column Data prin1_2; Input ID_number $ grade lname $ fname $ gender $; datalines ; 0100 3 Griffin Angela F 0200 3 James Ellen F 0400 4 Peeler Lane M 0600 6 Whitlock Nancy F 0700 4 Jenny Liu M ; Run ; proc print data =prin1_2 noobs ; var grade lname gender; Run ; Proc print data =prin1_2; var grade lname gender; ID ID_number fname; Run ; 3
Image of page 3

Subscribe to view the full document.

Note: Noobs option suppresses the printing of the default observation number. The ID statement, which automatically suppresses the printing of the observation number, tells SAS to print the variable(s) specified in the ID statement as the first column(s) of your output Example 4: Selecting Observations By default, a PROC PRINT step lists all the observations in a data set. You can control which observations are printed Adding a WHERE statement to your PROC PRINT step. There should be only one WHERE statement in a step. If multiple WHERE statements are issued, only the last statement is processed(conditional) using the FIRSTOBS= and OBS = options to tell SAS which range of observation numbers to print Data prin1_3; Input ID_number $ grade lname $ fname $ gender $; datalines ; 0100 3 Griffin Angela F 0200 3 Jamees Ellen F 0400 4 Peeler Lane M 0600 6 Whitlock Nancy F 0700 4 Jenny Liu M ; Run ; proc print data =prin1_3; var grade lname gender; Where lname contains 'ee' ; where gender in ( 'F' , 'M' ); /*if multiple where statement---last one is processed*/ Run ; 4
Image of page 4
Proc print data =prin1_3(firstobs= 2 obs = 4 ); Var grade gender; Run ; Example 5: Generating Column Totals To produce column totals for numeric variables, you can list the variables to be summed in a SUM statement in your PROC PRINT step.
Image of page 5

Subscribe to view the full document.

Image of page 6

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern