1 appendix a: writing and submitting sas ® programs a.1 writing and submitting sas programs

28
1 Appendix A: Writing and Submitting SAS ® Programs A.1 Writing and Submitting SAS A.1 Writing and Submitting SAS Programs Programs

Upload: martha-floyd

Post on 16-Dec-2015

219 views

Category:

Documents


0 download

TRANSCRIPT

1

Appendix A: Writing and Submitting SAS® Programs

A.1 Writing and Submitting SAS ProgramsA.1 Writing and Submitting SAS Programs

2

Objectives Create and submit new SAS programs. Insert existing programs into a project. List programming statements to avoid. Generate a combined project program and log.

3

SAS Enterprise Guide Program EditorSAS Enterprise Guide includes a programming editor similar to the Enhanced Program Editor.

Additional functionality in the SAS Enterprise Guide 4.3 Program Editor includes the following:

autocomplete dynamic syntax

tooltips formatting programs

to provideconsistent spacing

analyzing program flow

4

Writing a New SAS ProgramTo build a SAS program, select File New Programto create a new code node in the project. The new program is saved along with the project.

5

Adding Existing CodeTo add a shortcut in the project to an existing SAS program, select File Open Program….

6

Running SAS CodeA SAS program can be submitted using one of these techniques: Select Run or Run Selection from the toolbar. Select Program Run or Run Selection from

the Menu bar. Right-click on the program and select Run or

Run Selection. Press F8 or F3.

7

Accessing Program, Log and ResultsThe code, log, output data, and results are accessible via separate tabs.

8

Identifying Warning and Errors in the LogThe code icons in the project indicate whether there are warnings or errors in the SAS log.

Arrows on the Log tab enable quick navigation to the next warning or error.

9

10

A.01 QuizOpen the SAS program e1Aa01.sas in SAS Enterprise Guide and run it. Look at the log to identify any errors, correct the program, and rerun it.

Leave the project and program open for the next quiz.

e1Aa01.sas

11

A.01 Quiz – Correct AnswerOpen the SAS program e1Aa01.sas in SAS Enterprise Guide and run it. Look at the log to identify any errors, correct the program, and rerun it.

The data set should be named children.

e1Aa01.sas

12

Using the Program ToolbarA toolbar above the program offers easy access to common actions, such as the following: saving the program running or stopping a program selecting the execution server analyzing the program for flow or grid computing exporting and e-mailing creating a stored process modifying program properties

13

Embedding Programs in a ProjectNew SAS programs are embedded in the project so that it is saved as part of the .egp file.

When an existing SAS program is added to a project, a shortcut to the program file is created. You can also embed the program so that it is stored as part of the project file.

Select Properties from the Program toolbar and select Embed.

14

A.02 QuizEmbed the e1Aa01 program into the project by selecting the Properties button on the Program tab and selecting Embed OK. View the process flow.

How does the Code icon change?

e1Aa01.sas

15

A.02 Quiz – Correct AnswerEmbed the e1Aa01 program into the project by selecting the Properties button on the Program tab and selecting Embed OK. View the process flow.

How does the Code icon change?

The shortcut arrow is removed.

e1Aa01.sas

16

Using AutocompleteIn SAS Enterprise Guide 4.3, the Program Editor includes an autocomplete feature. The editor can suggest SAS statements procedures macro programs macro variables functions formats librefs SAS data sets.

17

Customizing the Program EditorThe Program Editor can be customized by selecting Program Editor Options.

Autocomplete can be customized or disabled on the Autocomplete tab.

18

Rearranging Windows

19

Linking Items in the Process FlowLinks define the directional relationship between objects in SAS Enterprise Guide to create a process flow. Links can be either automatic or user-defined.

Links can enable you to force a particular flow between programs and point-and-click tasks in the project.

User-Defined

Automatic

20

Adding a SAS Program to a Project

This demonstration illustrates adding and submitting a SAS program in a SAS Enterprise Guide project.

21

Exporting CodeAll SAS code within a project can be exported to a file that can be edited and executed in other SAS environments.

SelectFile Export Export All Codein Project….

22

Project LogThe project log can be used to maintain and export an aggregated log of all code submitted for the project.

23

24

Setup for the Poll1. Open the e1Aa01.egp project.

2. Select Project Log in the Process Flow window or select View Project Log.

3. Select Turn On.

4. Return to the Process Flow window and select Run Process Flow.

5. After the results are generated, select Run Process Flow a second time.

6. Examine the project log by selecting View Project Log.

25

A.03 PollIs the project log overwritten or appended when the project is run the second time?

Overwritten

Appended

26

A.03 Poll – Correct AnswerIs the project log overwritten or appended when the project is run the second time?

Overwritten

Appended

27

Programming Statements to AvoidPrograms that run in the SAS windowing environment can also run successfully in SAS Enterprise Guide. Be aware of the following exceptions:

Code that calls X commands or SYSTASK might not work unless this permission is granted by the administrator.

Code that would normally cause a window or prompt to appear in the SAS windowing environment (DEBUG, PROC FSLIST, AF applications) does not work in SAS Enterprise Guide.

Code that terminates the SAS process with ABORT or ENDSAS calls terminates the connection between SAS Enterprise Guide and the SAS server.

28