Fundamentals of Programming in SAS. James Blum

Чтение книги онлайн.

Читать онлайн книгу Fundamentals of Programming in SAS - James Blum страница 4

Автор:
Жанр:
Серия:
Издательство:
Fundamentals of Programming in SAS - James Blum

Скачать книгу

rel="nofollow" href="#fb3_img_img_8e6c27c6-2fb8-5bb2-91a2-03c8f2958572.jpg" alt="Figure 1.3.1: SAS Windowing Environment on Microsoft Windows"/>

      In the Microsoft Windows operating system, the menu and toolbars in the SAS windowing environment have a similar look and feel compared to other programs running on Windows. Exploring the menus reveals standard options under the File, Edit, and Help menus (such as Open, Save, Clear, Find). The View, Tools, Solutions, and Window menus have specialized options related to windows and utilities that are specific to SAS. The Run menu is dedicated to submissions of SAS code, including submissions to a remote session. As is typical in most applications, toolbar buttons in SAS provide quick access to common menu functions and vary depending on which window is active in the session. Some menu and toolbar options are reviewed below during the execution of the supplied sample code given in Program 1.3.1. This sample code is available from the author web pages for this book.

      Program 1.3.1: Demonstration Code

      options ps=100 ls=90 number pageno=1 nodate;

      data work.cars;

      set sashelp.cars;

      mpg_combo=0.6*mpg_city+0.4*mpg_highway;

      select(type);

      when(‘Sedan’,’Wagon’) typeB=’Sedan/Wagon’;

      when(‘SUV’,’Truck’) typeB=’SUV/Truck’;

      otherwise typeB=type;

      end;

      label mpg_combo=’Combined MPG’ typeB=’Simplified Type’;

      run;

      title ‘Combined MPG Means’;

      proc sgplot data=work.cars;

      hbar typeB / response=mpg_combo stat=mean limits=upper;

      where typeB ne ‘Hybrid’;

      run;

      title ‘MPG Five-Number Summary’;

      title2 ‘Across Types’;

      proc means data=cars min q1 median q3 max maxdec=1;

      class typeB;

      var mpg:;

      run;

      After downloading the code to a known directory, there are multiple ways to navigate to and open this code. Figure 1.3.2 shows two methods to open the file, each requiring the Editor window to be active.

      Figure 1.3.2: Methods for Opening SAS Code Files in the SAS Windowing Environment

Figure 1.3.2: Methods for Opening SAS Code Files in the SAS Windowing Environment

      Either of these choices launches a standard Microsoft Windows file selection window, which is used to navigate to and select the file of interest. Upon successful selection of the code, it appears in the Editor window, and is displayed with some color coding as shown in Figure 1.3.3 (assuming the Enhanced Program Editor is in use, the Program Editor window provides different color coding). It is not important to understand the specific syntax or how the code works at this point, for now it is used simply to provide an executable program to introduce some SAS fundamentals.

      Code submission can also occur in multiple ways, two of which are shown in Figure 1.3.3, again each method requires the Editor window to be the active window in the session. If multiple Editor windows are open, only code from the active window is submitted.

      Figure 1.3.3: Submitting SAS Code in the SAS Windowing Environment

Figure 1.3.3: Submitting SAS Code in the SAS Windowing Environment

      Typically, after any code submission the Results window activates and displays an index of links to various entities produced by the program, including output tables. While not all SAS code generates output, Program 1.3.1 does, and it may be routed to different destinations (and possibly more than one destination simultaneously) depending on the version of SAS in use and current option settings.

      In SAS 9.4, the default settings route output to an HTML file which is displayed in the Results Viewer, a viewing window internal to the SAS session. Previous versions of SAS rely on the Output window for tables, an option which remains available for use in the SAS 9.4 windowing environment, and other specialized destinations for graphics. Default output options can be set by navigating to the Tools menu, selecting Options, followed by Preferences from that sub-menu, and choosing the Results tab in the window that appears, as shown in Figure 1.3.4.

      Figure 1.3.4: Managing Output for Program Submissions

Figure 1.3.4: Managing Output for Program Submissions

      Among other options, Figure 1.3.4 shows the option for Create HTML checked and Create Listing unchecked. For tables, the listing destination is the Output window, so when Create Listing is checked, tables also appear in the Output window in what appears as a plain text form. It is possible to check both boxes, and it is also possible to check neither, whichever is preferred.

      In the remainder of this book, output tables are shown in an RTF form embedded inside the book text, outside of any SAS Results window. Appearance of output tables and graphs in the book is similar to what is produced by a SAS session, but is not necessarily identical when default session options are in place. Later in this chapter, the ability to use SAS code to control delivery of output to each of these destinations is demonstrated, along with use of the listing destination as an output destination for graphics files.

      SAS Studio and SAS University Edition (which are, for the remainder of this text, singularly referred to as SAS University Edition) interface with SAS through a web browser. Typically, the browser used is the default browser for the machine hosting the SAS University Edition session, but this is not a requirement. Figure 1.3.5 shows a typical result of launching SAS University Edition (in this case using the Firefox browser on Microsoft Windows), launching in visual programmer mode by default. A closer match to the structure of the SAS windowing environment is provided by selecting SAS Programmer from the toolbar as shown.

      Figure 1.3.5: SAS University Edition

Figure 1.3.5: SAS University Edition

      Opening a program is accomplished via the Open icon on the toolbar, as illustrated in Figure 1.3.6, and the opened code is displayed in a manner very similar to the that of the Enhanced Program Editor display shown in Section 1.3.1.

      Figure 1.3.6: Opening a Program in SAS University Edition

Figure 1.3.6: Opening a Program in SAS University Edition

      Though in a different position, the toolbar icon for submission is the same as in the SAS windowing environment, and selecting it produces output in the Results tab as shown in Figure 1.3.7.

      Figure

Скачать книгу