Method A: The QUICK EASY WAY (one-way tables only)

IF your output is relatively short and involves only one-way tables:

  1. Save your output in html format:Run your Procedure
    • Tools –> Options –> Preferences –> choose the “Results” tab and check the box that says “HTML”.
  2. Go to the “Results Viewer” to view the html output
  3. Copy and Paste the data cells from the Results Viewer to an Excel table!

Method B: Output your results as SAS data sets and Export to Excel

First, create an output dataset from the results of your frequency distribution. Here are examples of how to output your procedure results into a SAS data set:

  • For a one way table for a single variable (“v1freq” is the output dataset which will contain the frequency distribution for the “v1” variable)
    PROC FREQ DATA = mydata;
    TABLES v1 /OUT = v1freq;
  • For multiple one way tables you can use ODS (Output Delivery System) to create separate output datasets for the frequency distribution of each variable:
    • In the example below “mydatA” is a dataset in my WORK library.
    • The ODS output statement will create one dataset for each of the variables in the tables statement: “freqs” (which will contain the “name” variable) and “freqs1” which will contain the “v1” variable.
      PROC FREQ DATA = mydatA;
      TABLES name v1;
      ODS OUTPUT OneWayFreqs(match_all)=freqs;

Second, export the SAS data set to Excel:

  • Assuming the output SAS data set is stored in the mydat library:
    • Option 1:
      • From the SAS menu, click
        1. File –> Export Data –> library=”mydat”, member=dataset name –>
        2. Check “Standard Data Source” and choose your version of Excel from the picklist provided, –> Next –> Enter the locationwhere you wish to save the Excel file and name the file. –>
        3. Choose whether you want to save a Proc Export file as described in the next window (optional) –> Finish.
    • Option 2:
      • From the mydat library in the Explorer Window, right-click on the output SAS data set file, then choose View in Excel.

Method C: Output your results using ODS HTML BODY= statement

The ODS HTML BODY allows the user to save the results as an html file. Usually, the filename extension assigned to the file is .HTML. However, the user can opt to assign a .XLS extension so it can be read in Excel (although .HTML files can be read directly into Excel as well).

ODS HTML BODY = ‘C:thesisv1.xls’;
TABLES name v1;
ODS OUTPUT OneWayFreqs(match_all)=freqs;