/*Report system by Kaz www.estat.us This let you get results in MS-WORD directly--instead of (or in addition to) seeing it in SAS output window. The word document you get will have a table of content, as well as a dated coverpage and pages. Note XXX in some of the title statements. That is how you tell SAS to pagenate. In the example below, XXX occurs at two places, which means that the results will be reported on two separate pages. In the appendix (see the bottom of this file) you will see an MS-WORD macro. Put this into your WORD's system by clicking on TOOLS--> MACRO --> MACROS. Then click on EDIT and in the window you get copy the following. */ **********************************************************; %let name_of_doc=example; PROC PRINTTO PRINT="C:\temp\&name_of_doc..txt" new; RUN; options formdlim=' '; data Mynote;input Memo $ 1-100; cards; ************************************************************************************* Here you can write a memo. It will appear in the cover page of the Word document. ************************************************************************************* ; run; **********************************************************; proc print data=mynote noobs; title "Note"; run; proc means data=sashelp.Prdsal3; title "XXX Descriptive Statistics"; var predict actual; run; proc freq data=sashelp.Prdsal3; title "Frequency"; tables state; run; ods listing close; proc mixed data=sashelp.Prdsal3 covtest noclprint; class state product; model actual =predict product/solution ddfm=bw; random intercept/sub=state; random product/sub=state ; ods output Nobs=N solutionF=F CovParms=COV; run; ods listing; proc print data=N noobs; title "XXX Number of Observations"; run; proc print data=F noobs; title "Coefficient Table"; run; proc print data=COV noobs; title "Covariance Table"; run; **********************************************************; PROC PRINTTO PRINT=PRINT; quit; options noxwait noxsync; filename cmds dde 'WinWord|System'; data _null_; file cmds; put '[FileOpen .Name = "' "C:\temp\&name_of_doc..txt" '"]'; put '[pagemaker()]'; Put '[fileSaveAs "'"C:\temp\&name_of_doc..txt"'"]'; Put '[fileclose()]'; run; **********************************************************; /*APPENDIX: This is a MS-WORD macro. Put this into your WORD's system by clicking on TOOLS--> MACRO --> MACROS. Then click on EDIT and in the window you get paste the following. The window you will be seeing already contains a lot of macros. It is safe to add this at the bottom of the file, so it does not erase what is already there. Sub pagemaker() ' ' pagemaker Macro ' Macro recorded 3/3/2005 by kuekawa ' Selection.TypeParagraph Selection.TypeParagraph Selection.TypeParagraph Selection.MoveUp Unit:=wdLine, Count:=3 Selection.TypeText Text:="MEMO" Selection.TypeParagraph Selection.TypeParagraph Selection.Sections(1).Headers(1).PageNumbers.Add PageNumberAlignment:= _ wdAlignPageNumberRight, FirstPage:=True Selection.InsertDateTime DateTimeFormat:="M/d/yyyy", InsertAsField:=False, _ DateLanguage:=wdEnglishUS, CalendarType:=wdCalendarWestern, _ InsertAsFullWidth:=False Selection.TypeParagraph Selection.TypeParagraph Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting Selection.Find.Replacement.Style = ActiveDocument.Styles("Heading 1") With Selection.Find.Replacement.ParagraphFormat With .Borders(wdBorderLeft) .LineStyle = wdLineStyleSingle .LineWidth = wdLineWidth075pt .Color = wdColorAutomatic End With With .Borders(wdBorderRight) .LineStyle = wdLineStyleSingle .LineWidth = wdLineWidth075pt .Color = wdColorAutomatic End With With .Borders(wdBorderTop) .LineStyle = wdLineStyleSingle .LineWidth = wdLineWidth075pt .Color = wdColorAutomatic End With With .Borders(wdBorderBottom) .LineStyle = wdLineStyleSingle .LineWidth = wdLineWidth075pt .Color = wdColorAutomatic End With With .Borders .DistanceFromTop = 0 .DistanceFromLeft = 0 .DistanceFromBottom = 0 .DistanceFromRight = 0 .Shadow = False End With End With With Selection.Find .Text = "XXX" .Replacement.Text = " " .Forward = True .Wrap = wdFindContinue .Format = True .MatchCase = False .MatchWholeWord = False .MatchByte = False .MatchAllWordForms = False .MatchSoundsLike = False .MatchWildcards = False .MatchFuzzy = False End With Selection.Find.Execute Replace:=wdReplaceAll With ActiveDocument.Styles("Heading 1").ParagraphFormat .LeftIndent = InchesToPoints(0) .RightIndent = InchesToPoints(0) .SpaceBefore = 12 .SpaceBeforeAuto = False .SpaceAfter = 3 .SpaceAfterAuto = False .LineSpacingRule = wdLineSpaceSingle .Alignment = wdAlignParagraphLeft .WidowControl = True .KeepWithNext = True .KeepTogether = False .PageBreakBefore = True .NoLineNumber = False .Hyphenation = True .FirstLineIndent = InchesToPoints(0) .OutlineLevel = wdOutlineLevel1 .CharacterUnitLeftIndent = 0 .CharacterUnitRightIndent = 0 .CharacterUnitFirstLineIndent = 0 .LineUnitBefore = 0 .LineUnitAfter = 0 .AutoAdjustRightIndent = True .DisableLineHeightGrid = False .FarEastLineBreakControl = True .WordWrap = True .HangingPunctuation = True .HalfWidthPunctuationOnTopOfLine = False .AddSpaceBetweenFarEastAndAlpha = True .AddSpaceBetweenFarEastAndDigit = True .BaseLineAlignment = wdBaselineAlignAuto End With ActiveDocument.Styles("Heading 1").NoSpaceBetweenParagraphsOfSameStyle = _ False With ActiveDocument.Styles("Heading 1") .AutomaticallyUpdate = False .BaseStyle = "Normal" .NextParagraphStyle = "Normal" End With ActiveWindow.ActivePane.VerticalPercentScrolled = 0 With ActiveDocument .TablesOfContents.Add Range:=Selection.Range, RightAlignPageNumbers:= _ True, UseHeadingStyles:=True, UpperHeadingLevel:=1, _ LowerHeadingLevel:=3, IncludePageNumbers:=True, AddedStyles:="", _ UseHyperlinks:=True, HidePageNumbersInWeb:=True, UseOutlineLevels:= _ True .TablesOfContents(1).TabLeader = wdTabLeaderDots .TablesOfContents.Format = wdIndexIndent If ActiveWindow.View.SplitSpecial <> wdPaneNone Then ActiveWindow.Panes(2).Close End If If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _ ActivePane.View.Type = wdOutlineView Then ActiveWindow.ActivePane.View.Type = wdPrintView End If ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader ActiveWindow.ActivePane.VerticalPercentScrolled = 58 ActiveWindow.ActivePane.VerticalPercentScrolled = 0 If Selection.HeaderFooter.IsHeader = True Then ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter Else ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader End If Selection.TypeBackspace Selection.Font.Size = 8 Selection.TypeText Text:="by Kaz " Selection.ParagraphFormat.Alignment = wdAlignParagraphRight ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument End With Selection.WholeStory Selection.Font.Size = 8 ActiveDocument.SaveAs FileName:="temp.doc", FileFormat:=100, _ LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword _ :="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _ SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _ False End Sub */