1 / 53

HRP 223 - 2008

HRP 223 - 2008. Topic 7 – How Reports Work. When do I do what?. If you need to produce summaries of data down columns, use the Describe menu. If you need to summarize data across the rows (change the values in cells), use the Filter and Query tool. . Data Steps.

tamas
Télécharger la présentation

HRP 223 - 2008

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. HRP 223 - 2008 Topic 7 – How Reports Work

  2. When do I do what? If you need to produce summaries of data down columns, use the Describe menu. If you need to summarize data across the rows (change the values in cells), use the Filter and Query tool.

  3. Data Steps • You can do anything in data step but don’t. • Use the menu drive summaries. • There are three cases where you will want to do dataset processing because the menu options are too limited or missing and SQL is impossible or ridiculously hard for these tasks: • outputting to multiple data sets • doing the same task to a set of variables • tracking complex patterns across records (for example, you may want to keep a complex total as you process records for a person) or remembering what was on a previous record

  4. Retain It is a horrible way to organize data but some people use blanks to indicate you are on the same subject. This causes issues for SAS because SAS erases the PDV whenever it loads in new data. You need to tell it to remember values across records. You can tell SAS to retain (remember) variables.

  5. Retain The PDV wants to work like this:

  6. Retain You want to give the retained variable the subject ID when you have one.

  7. Retain If the ID is not missing, you want to copy the retained ID into the blank. You don’t need to copy lastDude into the new data set.

  8. Retain Both

  9. After Slicing and Dicing • After you build tables with the correct data, you will want to print reports. • Simple Tables • Complex Summaries • Numeric Summaries • Graphics • The Graphical User Interface in EG is excellent for these tasks but you will want to make some tweaks which I will show you.

  10. A Simple Printed Report Say you have a dataset with band names and album names and you want to print it in a report: Use the List Data… menu option from the Describe menu:

  11. Basic reports are easy.

  12. Looking Better

  13. Changing Code As you tweak checkboxes or other options, EG is rewriting code:

  14. How it Works • The code that is generated for visualization tasks does these things: • Cleans up old files before it tries to reuse the names • Sorts the data if needed (and drops extra variables if you don’t tell it otherwise) • Does the visualization • Deletes old files

  15. The code will look something like this:

  16. If your code looks different… I recommend setting this to never.

  17. Titles The titles look lousy. I want the title to say “Ray plays 5f_55 too loud” and “Ray plays Assemblage 23 too loud”, etc.. Use #byval(theVariable) to show the group as the title at the top of the page.

  18. Almost…. Closer….

  19. Niceties Add the code to left justify You can justify titles or footnotes to the left or right or add hyperlinks. Right click on the node that has the report and choose Open Last Submitted Code. Then type anything to have it make a copy for you to edit.

  20. Adding hyperlinks is easy also.

  21. File Names It is convenient to add the name of the project to titles or footnotes. There is an automatic macro variable called _clientprojectname which has the path to the project.

  22. %scan(&_clientprojectname, -1, \) This is a macro function that says parse the path into words by dividing only at \ and select the first word starting on the right.

  23. Macro Parameters in EG • You have seen a few examples of using macros and macro parameters in SAS code. • Macro is extremely useful to customize EG code. You can add in lists for drop down menus that appear when your project runs. • This is extremely useful for changing what happens when you run your projects. • More on this later.

  24. Looking at Data • There is a dataset in the Walker book where he looks to see if two categorical predictors impact the mean hemoglobin scores. • Cancer type • Active vs. placebo • I want to visualize the data first and use the formal statistics to confirm what I have seen.

  25. Summaries The Box Plot menu choice is an embarrassment. I want good looking boxplots, histograms and numeric summaries.

  26. By default you do NOT see outliers. Fix that.

  27. A lovely plot of white space…. With no mean symbols….

  28. Histograms The histograms you get from the Distribution Analysis tool are not too bad but I would not try to publish them.

  29. Cancer Type It looks like there are some subtle differences.

  30. SAS 9.2 SAS did major work to graphics in 9.2. I have not seen EG 4.2 yet but I am hopeful.

  31. Pretty Summary Tables Proc Tabulate is arguably the most user-hostile part of SAS. It is hidden nicely by the Summary Tables item under the Describe menu.

  32. Drag the classification variables into the table. Drag and drop the analysis variable.

  33. Drag and drop useful statistics.

  34. Drag All to the margins. Drag the analysis variable to the line below All.

  35. Drag in the statistics of interest.

  36. Set format and right click on areas to set properties like colors.

  37. This is what I got after a bunch of right clicking and tweaking the “Heading Properties” and one change to the Box Area.

  38. General Appearance I don’t like the general color scheme and I want this to go to a PDF file.

  39. Instant PDF Visit the Style Manager on the Tools menu to browse the different style templates.

  40. ODS The Output Delivery System is the subsystem of SAS that controls output, including file types created and the appearance of the content. You can take any block of code and surround it with instructions to use ODS to send the output from an analysis to different output “pipes.” There is no easy way to redirect output from several nodes in the flowchart into a single PDF. Right click and choose “Open Last Submitted Code” and copy it (the blocks of code you want) to combine them into a single new code node.

  41. Pipes • You open the ODS pipe by typing: odshtmlbody="path"; odspdf body ="path"; • You close it with the corresponding close statement: odshtmlclose; odspdfclose;

  42. or body Store the HTLM files and graphics here. Do not specify the exact location of the files. HTLM • My code to produce HTML looks like this: odshtml file=‘blah-body.htm' contents="blah-contents.htm" frame="blah-frame.htm" page="blah-page.htm" path ="c:\projects\blah\" (url=none) gpath="c:\projects\blah\" (url=none);

  43. Call it index.html if going to a webpage. ODS Example odshtml body="blah-body.htm" contents="blah-contents.htm" frame="blah-frame.htm" page="blah-page.htm" path ="c:\blah\" (url=none) gpath="c:\blah\" (url=none); procprintdata=blah;run; procprintdata=blah2;run; odshtmlclose;

  44. HTML Style Templates • You can add this to the ods html line to change the appearance of the output: /style= SomeStyle • Where SomeStyle includes lots of already made choices like: BarrettsBlue, Beige, Brick, D3d,Default, FancyPrinter, Minimal, NoFontDefault, Printer, RTF, SansPrinter, SASWeb, SerifPrinter, StatDoc • I usually use default, minimal, journal or printer .

  45. SAS wants to put titles into the document’s header. If you use “bodytitle” it will put the titles into the body of the text document. ODSfor Word Processing • If you want good looking output to go into a word processor, tell ODS to output into RTF (rich text format): odsrtffile = "c:\SomeName.rtf" bodytitle ; • At the end of the program include this: odsrtfclose;

  46. ODS Example • To get SAS to produce a subset of the output, you use the ods select subsectionName statement. odsselect BasicMeasures; procunivariatedata = repver.f_repver3; var age_st; run; • The trick is to figure out the name of the subsection you want. To find the subsection name, you can dig through the SAS documentation or just use the ODS trace statement.

  47. odstraceon; procunivariate data=repver.f_repver3; var age_st; run; odstraceoff; • After you have the names of the subsections you want, remember to remove or comment out the ods trace statements.

More Related