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

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

Dec 16, 2015

Download

Documents

Martha Floyd
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 1 Appendix A: Writing and Submitting SAS ® Programs A.1 Writing and Submitting SAS Programs.

1

Appendix A: Writing and Submitting SAS® Programs

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

Page 2: 1 Appendix A: Writing and Submitting SAS ® Programs A.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.

Page 3: 1 Appendix A: Writing and Submitting SAS ® Programs A.1 Writing and Submitting SAS Programs.

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

Page 4: 1 Appendix A: Writing and Submitting SAS ® Programs A.1 Writing and Submitting SAS Programs.

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.

Page 5: 1 Appendix A: Writing and Submitting SAS ® Programs A.1 Writing and Submitting SAS Programs.

5

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

Page 6: 1 Appendix A: Writing and Submitting SAS ® Programs A.1 Writing and Submitting SAS Programs.

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.

Page 7: 1 Appendix A: Writing and Submitting SAS ® Programs A.1 Writing and Submitting SAS Programs.

7

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

Page 8: 1 Appendix A: Writing and Submitting SAS ® Programs A.1 Writing and Submitting SAS Programs.

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.

Page 9: 1 Appendix A: Writing and Submitting SAS ® Programs A.1 Writing and Submitting SAS Programs.

9

Page 10: 1 Appendix A: Writing and Submitting SAS ® Programs A.1 Writing and Submitting SAS Programs.

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

Page 11: 1 Appendix A: Writing and Submitting SAS ® Programs A.1 Writing and Submitting SAS Programs.

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

Page 12: 1 Appendix A: Writing and Submitting SAS ® Programs A.1 Writing and Submitting SAS Programs.

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

Page 13: 1 Appendix A: Writing and Submitting SAS ® Programs A.1 Writing and Submitting SAS Programs.

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.

Page 14: 1 Appendix A: Writing and Submitting SAS ® Programs A.1 Writing and Submitting SAS Programs.

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

Page 15: 1 Appendix A: Writing and Submitting SAS ® Programs A.1 Writing and Submitting SAS Programs.

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

Page 16: 1 Appendix A: Writing and Submitting SAS ® Programs A.1 Writing and Submitting SAS Programs.

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.

Page 17: 1 Appendix A: Writing and Submitting SAS ® Programs A.1 Writing and Submitting SAS Programs.

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.

Page 18: 1 Appendix A: Writing and Submitting SAS ® Programs A.1 Writing and Submitting SAS Programs.

18

Rearranging Windows

Page 19: 1 Appendix A: Writing and Submitting SAS ® Programs A.1 Writing and Submitting SAS Programs.

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

Page 20: 1 Appendix A: Writing and Submitting SAS ® Programs A.1 Writing and Submitting SAS Programs.

20

Adding a SAS Program to a Project

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

Page 21: 1 Appendix A: Writing and Submitting SAS ® Programs A.1 Writing and Submitting SAS Programs.

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….

Page 22: 1 Appendix A: Writing and Submitting SAS ® Programs A.1 Writing and Submitting SAS Programs.

22

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

Page 23: 1 Appendix A: Writing and Submitting SAS ® Programs A.1 Writing and Submitting SAS Programs.

23

Page 24: 1 Appendix A: Writing and Submitting SAS ® Programs A.1 Writing and Submitting SAS Programs.

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.

Page 25: 1 Appendix A: Writing and Submitting SAS ® Programs A.1 Writing and Submitting SAS Programs.

25

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

Overwritten

Appended

Page 26: 1 Appendix A: Writing and Submitting SAS ® Programs A.1 Writing and Submitting SAS Programs.

26

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

Overwritten

Appended

Page 27: 1 Appendix A: Writing and Submitting SAS ® Programs A.1 Writing and Submitting SAS Programs.

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.

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

28