Showing posts with label Reporting. Show all posts
Learning SAS: How to create a SAS report in .html file using ODS?
In our previous blogposts, we discussed about different ways of tweaking the way we display our output. Now it's time for something more advanced. We're in the age of Web and sometimes our company might require our output in HTML format either to upload online or in the company's intranet portal, in either cases it's not efficient to give our output to a web designer and ask him/her to create a .html equivalent of our summary. Rather SAS has a great stuff called Output Delivery Syste (ODS in short) that can just push a .HTML file our report.
Problem 1:
Sending the output to an HTML file. Issue the appropriate commands to prevent SAS from creating a listing file. (19:1)
Solution:
Run the same procedures as shown in Problem 1, except use the JOURNAL (or FANCYPRINTER) style instead of the default style. (19:3)
Solution:
Problem 1:
Sending the output to an HTML file. Issue the appropriate commands to prevent SAS from creating a listing file. (19:1)
Solution:
ods listing close; ods html file='/folders/myfolders/iSAS/Assignment/2/college_report.html'; title "Sending Output to an HTML File"; proc print data=A15001.A01_college(obs=8) noobs; run; proc means data=A15001.A01_college n mean maxdec=2; var GPA ClassRank; run; ods;
Output:
Problem 2:
Run the same procedures as shown in Problem 1, except use the JOURNAL (or FANCYPRINTER) style instead of the default style. (19:3)
Solution:
ods listing close; ods html file='/folders/myfolders/iSAS/Assignment/2/college_report.html' style=FancyPrinter; title "Sending Output to an HTML File"; proc print data=A15001.A01_college(obs=8) noobs; run; proc means data=A15001.A01_college n mean maxdec=2; var GPA ClassRank; run; ods;
Output:
Learning:
- How to use ODS to output a HTML file of the report
- How to use different styles while creating the HTML report file using ODS
Learning SAS: How to sort variables while displaying the frequency output?
Sometimes it's not desirable just to display the output of the PROC FREQ as it is. As an analyst, sometimes our organization would require us to tweak it a bit.
Problem:
Using the SAS data set Blood, produce a table of frequencies for BloodType, in
frequency order. (17:7)
Solution:
/*Using the SAS data set Blood, produce a table of frequencies for BloodType, in frequency order.*/ TITLE 'FREQUENCY OF CHOLESTROL GROUPED ORDERED BY INPUT DATA'; PROC FREQ DATA=A15001.A01_BLOOD ORDER=DATA; TABLE BLOODTYPE; RUN; TITLE 'FREQUENCY OF CHOLESTROL GROUPED ORDERED BY INPUT FREQUENCY'; PROC FREQ DATA=A15001.A01_BLOOD ORDER=FREQ; TABLE BLOODTYPE; RUN; TITLE; Output:
Learning:
- How to change the order of variables displayed in the PROC FREQ Output
Learning SAS: How to create Summary Dataset using PROC MEANS
As we mentioned in the previous post, PROC MEANS is our handy option to create a new summary dataset that can be used in other data steps or Procedures. Here we'll show how to create a summary dataset using PROC MEANS.
Problem:
Using the SAS data set College, create a summary data set (call it Class_Summary) containing the n, mean, and median of ClassRank and GPA for each value of SchoolSize. Use a CLASS statement and be sure that the summary data set only contains statistics for each level of SchoolSize. Use the AUTONAME option to name the variables in this data set.
Solution:
Output:
Problem:
Using the SAS data set College, create a summary data set (call it Class_Summary) containing the n, mean, and median of ClassRank and GPA for each value of SchoolSize. Use a CLASS statement and be sure that the summary data set only contains statistics for each level of SchoolSize. Use the AUTONAME option to name the variables in this data set.
Solution:
/* create summary dataset from proc means */ /* NWAY to display only the Schoolsize level type */ proc means data=A15001.A01_College NOPRINT NWAY; CLASS SchoolSize; var ClassRank GPA; Output out=A15001.A01_Class_Summary N=Mean=Median= /Autoname; run; Title 'Grouped Summary Statistics of ClassRank & GPA by Schoolsize'; proc print data=A15001.A01_Class_summary; run; Title;
Output:
Learning:
- How to efficiently use PROC MEANS to create a summary dataset
- What's the purpose of NWAY option in PROC MEANS
- How to automatically name the variables in the newly created Summary dataset