Macro %Report – Standard Scripts
This is a PhUSE collaboration project to provide a macro called %report which can be used to create outputs in a simple way. So this macro can be used instead of PROC REPORT. Please help us to enhance this macro by giving feedback, change requests, participate in the implementation, documentation, bug reporting, validation etc. With collaboration this macro can become very powerful and helpful for all of us.
This macro is based on the work of the PhUSE/FDA CSS group 5 “Development of Standard Scripts for Analysis and Programming” and uses the “Good Programming Practice” principles.
License and Disclaimer
The MIT license is used for this macro: http://opensource.org/licenses/MIT
Copyright (c) 2012 (PhUSE?)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
The following example displays the purpose of the macro:
TITLE "Example - simple CLASS example with BY"; %report(data = sashelp.class, var = age height weight, by = sex name);
Example - simple CLASS example with BY Sex Name Age Height Weight --------------------------------- F Alice 13 56.5 84 Barbara 13 65.3 98 Carol 14 62.8 102.5 Jane 12 59.8 84.5 Janet 15 62.5 112.5 Joyce 11 51.3 50.5 Judy 14 64.3 90 Louise 12 56.3 77 Mary 15 66.5 112 M Alfred 14 69 112.5 Henry 14 63.5 102.5 James 12 57.3 83 Jeffrey 13 62.5 84 John 12 59 99.5 Philip 16 72 150 Robert 12 64.8 128 Ronald 15 67 133 Thomas 11 57.5 85 William 15 66.5 112
By now the macro is a standalone macro and provides the following parameters:
|DATA||SAS input dataset, can contain WHERE, KEEP and similar conditions, e.g. SASHELP.CLASS(WHERE=(sex = ‘M’))|
|VAR||Variable(s) of DATA to be printed|
|BY||Variable(s) to group and print|
|PAGE||Variable(s) to group and print. Printout above table start and starting a new page for all new values|
|MSGLVL||Option to define the levels of notes you want to get from this macro. 0: No additional messages, : BAsic messages about the progress, Values above 1 not jet defined|
Following additional functionality is implemented:
|Existence Checks||DATA and VAR needs to be given|
DATA needs to be an existing valid dataset (WHERE, KEEP etc. supported)
|Column Width calculation||
The column widths of all BY and VAR variables are calculated based on the longest content & title of the corresponding column.
|Continued Flag||A continued flag is printed on all pages but the last.|
Requirements and Assumptions
- SAS 9.2 (maybe others as well)
- No formal validation is performed
- Simple quality checks are performed and can be found in a validation script (see documents section)
- Be aware that the code can be changed by anyone anytime
- Macro Source: File:Report.sas.txt
- Example Validation Program: File:Report validation.sas.txt
- Example Call Program: File:Report example.sas.txt
- Example Call Output: File:Report examples.txt
Please report any change ideas you may have. Some could be discussed and some may be implemented some when. When you work on a change requests or have implemented and published those, please change the status. Use the status “Open” for new requests, “Ongoing” when you try to implement them and are going to publish a solution and “Finished” when done.
|Change001||Support printout of empty datasets containing variable labels and a “No Data Available” line (or similar) (KatjaGlass 2012-10-19)||open|
|Change002||Provide a nice DOC User Guide (KatjaGlass 2012-10-19)||open|
|Change003||Create nice lines, meaning one after the TITLEs and if available PAGE variable and one before the FOOTNOTEs (KatjaGlass 2012-10-19)||open|
|Change004||Include the PAGE label in the printout (KatjaGlass 2012-10-19)||open|
|Change005||Left align the output table (currently 2 leading spaces) (KatjaGlass 2012-10-19)||open|
|Change006||Support VAR=_ALL_, but exclude variables in PAGE and BY (KatjaGlass 2012-10-19)||open|
|Change007||Implement a better column widths calculation (KatjaGlass 2012-10-19)||open|
|Change008||Implement an ORDER variable, variables in BY and ORDER should not be printed and only be used for ordering purposes (KatjaGlass 2012-10-19)||open|
|Change009||Use a center alignment for column labels of VAR variables for BY use left alignment. (KatjaGlass 2012-10-19)||open|
Please report any found bugs. When you work on a bug-solution or have implemented and published those, please change the status. Use the status “Open” for new bugs, “Ongoing” when you try to fix them and are going to publish a solution and “Finished” when done.
|Bug001||Empty input datasets are not supported and abort with no catch message (KatjaGlass 2012-10-19)||open|
|0.1 (2012-11-01)||KatjaGlass||Initial creation containing DATA, PAGE, BY, VAR, column width calculation, continued footer|
Please participate in this project. Even if you only include change requests, bug fixes, then the community can take those items up. Even better if you participate also in creating implementations and documentations and join discussions. Please change available source, when you see enhancements in case of performance or simplify the source. Please do not use hardly to understand source and include comments.
Please enter items you want to discuss as many things can be handled very differently. The main goal for this macro is to keep things simple and reduce complexity by providing enough flexibility.