10
Data Output

Output is very important in analysis to show the results of data science to stakeholders. It can primarily be Excel, Powerpoint, and Word documents for data analysis. With the advent of cloud and collaboration tools, there are many ways to communicate the intermediate stages of data analysis. The following shows ways to show output in R and SAS.

10.1 Data Output in SAS

There are two ways:

  1. Proc Export‐ Proc Export can export data in many formats

Here, replace will replace an earlier file with same name

  1. ODS

ODS stands for output delivery system. It is used to format the output of a SAS program. We can output data by putting output print within ODS HTML and ODS HTML CLOSE. Here we output the PROC Means of a dataset to a different object and print it to an excel file.

  1. Images
Snipped image of a SAS Studio window displaying a list of graphs under Tasks and Utilities in the left panel and settings at the right panel.

Figure 10.1 Creating plots in SAS.

Output is in the form of an HTML page which can be saved.

HTML output plot in SAS displaying horizontally aligned circles lying on the horizontal lines for hybrid, truck, wagon, sports, sedan, and SUV. Save image as option is highlighted in the right-click menu at the center.

Figure 10.2 HTML output plot in SAS.

10.2 Data Output in R

Here we change a working directory to the output folder. We take an object (or create an output dataframe, or object, then output them write.csv (just as we used read.cev to input data).

We can also use fwrite in the data table package.

We can also use write_csv in readr package

For Graphs we can export plots in 3 Ways in RStudio: Picture, PDF, and Copy to Clipboard.

Snipped image of Save Plot as Image dialog box displaying expanded selection box for Image format with options for PNG, JPEG (highlighted), TIFF, BMP, Metafile, SVG, and EPS. Save and Cancel buttons are at the bottom right.

Figure 10.3 Output format for plots in R.

However, there are seven types of images.

We can also have html, pdf and word output of code and output. We can download them locally and also publish it on RPubs; a repository website provided by RStudio.

html output using the knit package/button in RStudio,can be opened in the browser, published and shared on Rpubs.

We have this code:

We use knit as follows:

Snipped image displaying an expanded file menu displaying Knit Document option being highlighted. Other portions being displayed are Compile Report, Save, Save As, Save with Encoding, Print, etc.

Figure 10.4 Knit document in R studio.

We have three types of output‐ HTML, Word, PDF by using Knit. Let’s take the HTML output here:

This is our output.

Snipped image displaying HTML output by knit in R. A scatter plot is observed at the bottom-left corner. A Publish dialog box at the center displays two options for RPubs and RStudio Connect.

Figure 10.5 HTML output by knit in R.

We can open it in the browser on the top left. We can publish it to RPubs using the Publish button on the top right. For secure publishing we can use RConnect.

We can also create Markdown documents of R Code by rmarkdown library.

R Markdown is a file format for making dynamic documents with R. An R Markdown document is written in markdown (an easy‐to‐write plain text format) and contains chunks of embedded R code, like the document below. ‐‐‐ output: html_document ‐‐‐ This is an R Markdown document. (see https://rmarkdown.rstudio.com/articles_intro.html)

10.3 Quiz Questions

  1. How many types of image formats can be down in RStudio?
  2. What package in R can create markdown of R Code?
  3. In which website can you publish R Code but privately?
  4. What are the three types of output by using knit in RStudio?
  5. What command writes data in data. table package in R?
  6. What proc. writes data in SAS?
  7. What does ODS stand for?
  8. How do we close ODS code?
  9. How can we save pictures in SAS?
  10. What does REPLACE do in Proc Export?

Quiz Answers

  1. 7
  2. rmarkdown
  3. R Connect
  4. HTML, Word, PDF
  5. fwrite
  6. Proc Export
  7. Output Delivery System
  8. ODS HTML Close
  9. Saving Image from a HTML page
  10. Replaces the file with existing name in PROC EXPORT so program can be run repeatedly.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.184.189