SAS job

profilestrength
week7.zip

week 7/Invited Talk_PMenu.pptx

Business Analytics with SAS®

PROC PMENU

Suntish T. Narain
MSc Big Data Analytics
06th March 2018

Hello everyone

My name is Suntish and I am from the Big Data Analytics programme

I am here today to walk you through the steps of creating menus, windows and frames

Contents

An overview of Proc PMENU

Proc PMENU syntax and templates

Associating a menu to a window

Creating a dialog box

Introduction to Frames in SAS®

Overview of the Build Environment

Associating Controls and Models to Frames

Associating a menu to a frame

In this presentation, I will introduce you to PMENU procedure, what it is and how we can use it in the SAS application

We will look at creating a menu and the steps involved

We will then look at building a dialog box with radio buttons, checkboxes and text input

The second part of the presentation will be based on frames, how to create them and the build environment

We will look at the components that you can use to create a frame

Finally we will associate a menu to a frame

PROC PMENU - An Overview

The first part is an introduction to PMENU, what it is and how we can use it to define menus

PROC PMENU - Overview

What is the PMENU procedure in SAS?

Menus that can be used in DATA step windows

Any SAS app that enables you to specify customized menus

Why is it important?

Menus can replace command line to execute commands

How does it work?

Activate menu for it to appear

Menus list items that you can select

The PMENU procedure defines menus that can be used in DATA step windows or in any SAS application that enables you to specify customized menus.

Menus can replace the command line as a way to execute commands.

PMENU commands are issued from any command line to activate menus.

When menus are activated, each active window has a menu bar, which lists items that you can select.

The PMENU procedure produces no immediately visible output. It simply builds a catalog of entry of type PMENU that can be used later in an application.

PROC PMENU – Procedure Execution

Multiple menus can de defined by separating their definitions with RUN statements

A group of statements that ends with a RUN statement is called a RUN group

You must completely define a PMENU catalog entry before submitting a RUN statement

Include an initial MENU statement that defines the menu bar

All ITEM statements and any SELECTION, MENU, SUBMENU or DIALOG statements should be within the same RUN group

libname proclib 'U:\My SAS Files\MENU';

proc pmenu catalog=proclib.mycat;

menu menu1;

item end;

item bye;

run;

menu menu2;

item end;

item pgm;

item log;

item output;

run;

menu menu3;

item end;

item pgm;

item log;

item output;

run;

Each menu should be within the RUN statement

The following statements define two separate PMENU catalog entries.

Both are stored in the same catalog, but each PMENU catalog entry is independent of the other.

PROC PMENU – Templates

Create a menu bar with an item that produces a menu

Create a menu bar with an item that opens a dialog box, which displays information and requests text input

PROC PMENU – Templates

Create a menu bar with an item that opens a dialog box, which permits one choice from a list of possible values

Create a menu bar with an item that opens a dialog box, which permits several independent choices

Associating a menu to a window (1)

Point the library to an appropriate location

libname <library_name> ‘<sas_library_location>’;

Create the catalog to store the menu definitions

proc pmenu catalog=<library_name>.<catalog_name>;

The MENU statement specifies select as the name of the catalog entry

The item statements specify the items for the menu bar

Assign a menu to the window

window <window_name> menu=<library_name>.<catalog_name>.<menu_name>

As with any SAS application that you create, a library needs to be specified – creating a menu is no different.

The second statement specifies the catalog in which you want to store the PMENU entries

It invokes the PMENU procedure and specifies where to store all PMENU catalog entries that are created in the PROC PMENU step.

The window statement creates a window. The menu statement associates a menu from the catalog entry to the window.

Associating a menu to a window (2)

1

2

3

menu sa;

item 'BRFSS_Population' dialog=size_sa;

dialog size_sa 'where @1';

text #1 @1 'Enter sample size: ';

text #2 @3 'Sample size <400k';

text #2 @25 len=7;

proc pmenu catalog=proclib.menusun;

menu suntish;

item 'File' menu=f;

item 'Visualisations' menu=v;

item 'Statistics' menu =s;

item 'Sample Selection' menu = sa;

item 'Print Report' menu=print;

item 'Copyright' menu=copyright;

data _null_;

window BRFSS_Suntish menu=proclib.menusun.suntish

#4 @10 ' Business Analytics with SAS '

#5 @10 '---------------------------------'

#6 @10 ' Suntish T. Narain '

#7 @10 ' MSc Big Data Analytics '

#8 @10 '---------------------------------'

#10 @10 ' Example of a SAS application '

#12 @10 'This SAS application will create '

#13 @10 'a menu & associate it to a window'

#14 @10 '---------------------------------‘

#16 @10 '-------- 06th March 2018 --------';

display BRFSS_Suntish;

run;

In section 1:

Declare a library. In this case, PROCLIB is used to store menu definitions.

Second, a catalog is specified for storing menu definitions. Menu definitions will be stored in the PROCLIB.MENUSUN catalog.

Then, a catalog entry is defined. In this case it’s Suntish. The menu statement specifies Suntish as the name of the catalog entry.

Now, we start designing the menu bar. The item statements specify the items for the menu bar.

In Section 2

We start to design the ‘Sample Selection’ menu

A dialog box is created and various text are placed to enable data entry from the user

In Section 3

The window statement defines the primary window of an application

The menu= option associates the catalog entry with this window

The display statement shows the BRFSS_Suntish window

Dialog Box – A MENU Option

WBUILD is a SAS macro. The field numbers %1, %2, and %3 equate to the values that the user specifies with the radio buttons. The field number @1 equates to the search value that the user enters. The field number &1 to &4 equates to the selection the user makes for the checkboxes.

Radiobox statement

Must be used after a DIALOG statement. Must be followed by one or more RBUTTON statements.

Text statement

This is a text string that appears inside the dialog box at the location defined by line and column

Checkbox statement

The checkbox statement requires a column and a line in order to place it in the dialog box. The text describes the check box. The option <ON> is used only if you want the checkbox to be selected at runtime.

Each CHECKBOX statement defines a single item that the user can select independent of other selections.

FRAME - Creating a SAS® Application

Introduction to Frames

What is a frame in SAS®?

Window that contains the fields and buttons that make up the application

How are frames created?

Application is built visually using drag and drop components in the Build Environment

Applications are stored in SAS catalogs

Applications are portable to all SAS software platforms

Building Application - SAS® components

Controls (Checkboxes, Listboxes, Entry fields & Table Viewer)

Models – link data to controls

A frame is defined as the application window that contains the interface, the components of the GUI with which the user interacts

This presentation will guide you through the basic skills that is required to build a simple frame application and associate a menu to it.

In SAS, components are pieces of software that you can use to build an application. Controls and Models are the two types of components that we will look at.

Controls are the visual components of the graphical user interface like checkboxes, radio buttons, Listboxes and table viewer

Models, on the other hand, works behind the scenes to distribute data to controls

We will look at those models in more details as we proceed through this presentation

SAS® Development Environment

The build environment has 4 main windows:

The Build Window (Frame)

This is where the GUI is designed for the application’s look and feel

The Components Window

Repository for controls and models

The Source Window (Source Code)

Text editor for SCL programs

Several source windows opened at the same time

The Properties Window

This is where the characteristics of the components are displayed

Only one properties window can be opened at any one time

Build Window (Frame)

-A frame is where the GUI of the application is built

-Frames are displayed in Build windows

-You can have several frames in one application

The Components Window

This is where the controls and models are located.

The components are dragged and dropped in the Build Window

The Source Window

This is a text editor for creating and editing programming code.

There can be several source windows opened at the same time

This is where SAS Component Language (SCL) programs are added to frames

The Properties Window

- This is where all the properties of all the components on a frame is displayed

- Properties are the defining characteristics of a component

- You can only open one properties window and that window is shared between all open frames

Frame Creation – Associating Control

Execute the below command into the SAS® Command Line to bring up the Build Window

build sasuser.example.Display_data_sun.frame

This is the name of the Frame

When the command is executed, an empty frame appears and the Components window is displayed

From the components window, the user can select items they want in the frame and drag & drop in the Build area.

In this example, a label was used to insert the title of the application window.

3 listboxes have been inserted into the frame.

3 push buttons have been used

Finally, a tableviewer is inserted, which will display the data in table format.

Frame Creation – Associating models

A Library List Model is dragged onto the List Box labelled Select Library (LibrariesListbox)

A Data Set List Model is dragged onto the List Box labelled Select Table (TablesListbox)

A Variable List Model is dragged onto the List Box labelled Select Columns (ColumnsListbox)

A SAS Data Set Model is dragged onto the Table Viewer (Tableviewer1)

Models and controls are designed to work with each other

To provide controls with data, associate them with models

Dropping a model onto a control sets the model attribute on the control

Models and controls are designed to work with each other.

To connect models and controls at build time, simply drag a model onto a control when you are designing the frame, and SAS sets the connection for you. 

To provide all the controls with data, you need to associate them with models.

Dropping a model onto a control sets the model attribute on the control, which is all you need to do to associate a control and a model. 

Frame Creation – Introducing SCL code

SAS Component Language (SCL) controls SAS applications (including controls and frames)

SCL programs are stored in SCL entries, separately from frames.

SCL program or function can be written once and used many times

SCL is an OOP Language, designed to facilitate development of interactive SAS applications

Frame SCL is an SCL entry that is associated with a particular frame

Frame SCL is used to control a frame and the components on that frame

SAS Component Language is the programming language that controls SAS applications (including controls and frames)

SCL is an object-oriented programming language that was designed to facilitate the development of interactive SAS applications

Frame Creation – Frame SCL code

Frame SCL uses reserved sections for program initialization and termination

INIT section executes once before frame is displayed

It is used to initialise variables and open SAS tables

TERM section executes once before the frame is closed

It is used to close the tables and delete variables

Each variable that is used in SCL is of a specific data type (CHAR, NUM and LIST)

All variables should be declared using the DECLARE statement or DCL for short

INIT:

dcl num variable1 rc; /* Declares two numeric variables. */

dcl list myList={}; /* Declares an empty list. */

return;

TERM:

rc=dellist(myList); /* Deletes the list myList. */

return;

Frame SCL uses reserved sections for program initialization and termination 

The INIT section executes once before the frame is displayed to the user

It  is typically used to initialize variables and open SAS tables

The TERM section executes once before the frame is closed

It is typically used to close tables and delete variables that are no longer needed

Frame Creation – Associating SCL code

Variables are instantiated

Init:

Executes before the frame is displayed to the user

LibrariesListBox:

Executes when a selection is made from the LibrariesListbox

TablesListbox:

Executes when a selection is made in the TablesListbox

ColumnsListbox:

Executes when a selection is made in the ColumnsListbox

SubsetButton:

Runs a filter when the button is pressed

ClearButton:

Clears the filter when the button is pressed

term:

Deletes the list when quitting

We first start with the declaration of the variables

SCL code is added to the frame to make it fully functional.

The Source code window is the window in which SCL programs are written

For this application, the SCL code has the following methods.

Frame Creation – Associating SCL code

Variables are instantiated

Initialising the Frame

Term:

dcl num rc;

dcl char(30) displayTable;

dcl list emptyList={};

Init:

subsetButton.enabled='no';

clearButton.enabled='no';

datasetlist1.levelCount=1;

return;

/*************************************/

/* Procedure is executed before the frame is */ /* created – buttons are also reset and the */

/* table option is also set to display data. */

/*************************************/

/************************************/

/* Numerical variable used as a return code */

/* displayTable variable of type character is */ /* created – An empty list is created */

/************************************/

term:

rc=dellist(emptyList);

return;

/*************************************/

/* used to close tables and delete variables */

/* and lists that are no longer needed */

/*************************************/

Variables are initialised at run time so they can be used later on in the program

Init procedure is executed once before the frame is displayed to the user

At runtime, there is nothing to subset or clear, hence why it disables the subsetButton and clearButton by setting the enabled attribute to ‘no’

It also set how the table is displayed in the TablesListBox.

The TERM section executes once before the frame is closed, and is typically used to close tables and delete variables that are no longer needed. You should always delete lists when they are no longer needed

Frame Creation – Associating SCL code

LibrariesListbox:

LibrariesListbox:

if LibrariesListbox.selectedItem ne ' ' then

do;

datasetList1.library=librariesListbox.selectedItem;

variableList1.dataSet=' ';

sasdataset1.table=' ';

subsetButton.enabled='yes';

end;

return;

/******************************************/

/* The dataset library points to the selected */

/* item - The variable list box remains empty */

/* The subset button is enabled. */

/******************************************/

It sets the data set list model to point to the library selected. Since the data set list model is associated with the TablesListbox, the latter is populated.

The procedure also enables the subsetButton as there is now data to subset

Frame Creation – Associating SCL code

TablesListbox:

TablesListbox:

if TablesListbox.selectedItem ne ' ' then

do;

displayTable=librariesListbox.selectedItem || '.' || TablesListbox.selectedItem;

sasdataset1.table=displayTable;

variableList1.dataSet=displayTable;

SubsetButton.enabled='yes';

end;

return;

/************************************************/

/* Concatenate the selected library and the selected table */

/* and give the result to the sasdataset model, the model */

/* supplying the Table Viewer with data. */

/************************************************/

It sets the data set list model to point to the library selected. Since the data set list model is associated with the TablesListbox, the latter is populated.

The procedure also enables the subsetButton as there is now data to subset

The TablesListbox is executed when a selection is made

It concatenates the selected Library with the selected dataset (table). This information is then relayed to the sasdataset model supplying the table viewer.

The subset button remains enabled

Frame Creation – Associating SCL code

ColumnsListbox:

SubsetButton:

ClearButton:

ColumnsListbox:

if listlen(columnsListbox.selectedItems) gt 0 then

sasdataset1.columnOrder=copylist(ColumnsListbox.selectedItems);

return;

/*************************************/

/* Copy the list of selected columns to the */

/* sasdataset1 model, the model supplying */

/* the Table Viewer with data. */

/*************************************/

SubsetButton:

if sasdataset1.table ne ' ' then

rc = sasdataset1._setWhere(0, 'y');

if rc=0 then ClearButton.enabled ='yes';

return;

/*************************************/

/* Call the WHERE subset window */

/* If a WHERE expression is in effect enable */

/* the 'Clear Subset' button */

/*************************************/

ClearButton:

if sasdataset1.table ne ' ' then

sasdataset1._setWhere(emptyList);

ClearButton.enabled ='no';

return;

/********************************/

/* Clear the WHERE expression. */

/* Disable the 'Clear Subset' button. */

/********************************/

This is executed when the selection is made from the ColumnsListbox

The SubsetButton is executed when it is pressed. It calls the subset window – if an expression can be built using the where statement, the Clear Subset button is enabled.

The ClearButton clears the WHERE expression and disables the button – this is because there is no WHERE expression to be cleared anymore

Frame Creation– Testing the Frame

First, a Library is selected

Then a dataset is selected

The data is displayed in the table

and the variables are listed in the columns list

1st

2nd

3rd

4th

When the Application is tested, the user is now enabled to select any of the active libraries in the list.

When you select SAShelp, as in this example, the list under table gets populated.

For example, if Class is selected, both the table and the variable list get populated.

Frame Creation – Testing the Frame

When the user press on the Subset button, a window appears prompting the user to select which subset of data they would like to see.

As you select the attributes, it is listed in the Where section. In this example, Students where Gender is ‘F’ is selected. The results is displayed in the table.

To close the window, the close window is pressed. This ends the program.

FRAME – Associating a MENU

Associating a menu to a Frame - PMENU

Run the command “sasuser.example.Display_data_brfss.frame” to bring up the Frame Build window

Open the Properties of the Frame

In SAS, run the command to bring up the frame in the Build window

Now, In the Build environment, open up the Properties window

Associating a menu to a Frame - PMENU

Ensure that the Properties of the Frame is displayed

Locate the pmenuEntry under the Attribute Name column in the properties window

In the value column, click on the ellipsis… to navigate to the menu

Associating a menu to a Frame - PMENU

Select the Library ‘Proclib’ and then the catalog ‘Menusun’

Select the pmenu catalog entry in the list on the right hand side – ‘Suntish’ is selected. Click OK.

In the Build environment, open up the Properties window

In the value section of the pmenuEntry attribute name, select the ellipsis

Browse through the library and select the menu from the catalog

Test the Frame and the menu will appear

Associating a menu to a Frame - PMENU

On the Build Window, now select Build -> Test to launch the application

On the menu bar, the new sample menu should appear.

In the Build environment, open up the Properties window

In the value section of the pmenuEntry attribute name, select the ellipsis

Browse through the library and select the menu from the catalog

Test the Frame and the menu will appear

Review

Introduced to PROC PMENU

Associated a menu to a window

Created a Dialogbox

Incorporated rbutton, checkboxes and text fields

Introduced to Frames

Component, properties, source windows

Built a demo frame

Buttons, Listbox, table viewer and labels

Added the SAS Component Language (SCL) code

Compiled and Tested the Application

Associated a menu to a frame

week 7/UML Summary.pptx

Data Management and Business Intelligence 5CC519

www.derby.ac.uk/engtech

UML summary

http://www.tutorialspoint.com/uml

Dr John Panneerselvam

College of Engineering and Technology, University of Derby

Sensitivity: Internal

1

www.derby.ac.uk/engtech

UML stands for Unified Modelling Language.

UML is not a programming language like C++, Java, COBOL etc.

UML is a pictorial language used to make software blueprints

UML can be described as a general purpose visual modelling language to visualize, specify, construct and document software system.

Also used to model non software systems, e.g. process flow in a manufacturing unit etc.

UML Introduction

Sensitivity: Internal

2

www.derby.ac.uk/engtech

Define a general purpose modelling language which all modellers can use

Simple to understand and use.

Wide audience: developers, business users, ordinary people with a need to understand a “system”.

The “system” may or may not be software. UML is not a development method, rather an accompaniment process to make a successful system.

A simple modelling mechanism capable of modelling all possible systems.

Goals of UML

Sensitivity: Internal

3

www.derby.ac.uk/engtech

Things

Structural

Behavioural

Grouping

Annotational

Relationship

UML Diagrams

UML Building Blocks

Sensitivity: Internal

4

www.derby.ac.uk/engtech

Things

Structural

Class

Interface

Collaboration

Use case

Active classes

Components

Nodes

Behavioural

Interaction

State machine

Grouping

Package

Annotational

Note

Sensitivity: Internal

5

www.derby.ac.uk/engtech

Dependency

Association

Generalisation

Realisation

Relationship

Sensitivity: Internal

6

www.derby.ac.uk/engtech

Diagrams

Structural Diagrams

1. Class diagram

2. Object diagram

3. Component diagram

4. Deployment diagram

Behavioural Diagrams

5. Use case diagram

6. Sequence diagram

7. Collaboration diagram

8. Statechart diagram

9. Activity diagram

Sensitivity: Internal

7

Diagrams: Structural: Class Diagram

Class diagrams are the most common diagrams used in UML. Class diagram consists of classes, interfaces, associations and collaboration.

Class diagrams basically represent the object oriented view of a system which is static in nature.

Active class is used in a class diagram to represent the concurrency of the system.

Class diagram represents the object orientation of a system. So it is generally used for development purpose. This is the most widely used diagram at the time of system construction.

www.derby.ac.uk/engtech

Sensitivity: Internal

8

Class Notation

Top section used to name the class.

Second section used to show the attributes of the class.

Third section describes the operations performed by the class.

Final section is optional. Used to show any additional components.

www.derby.ac.uk/engtech

Sensitivity: Internal

9

Sample Class Diagram

www.derby.ac.uk/engtech

Sensitivity: Internal

10

Diagrams: Structural: Object Diagram

Object diagrams can be described as an instance of class diagram. So these diagrams are more close to real life scenarios where we implement a system.

Object diagrams are a set of objects and their relationships just like class diagrams and also represent the static view of the system.

The usage of object diagrams is similar to class diagrams but they are used to build prototype of a system from practical perspective.

www.derby.ac.uk/engtech

Sensitivity: Internal

11

Sample Object Diagram

www.derby.ac.uk/engtech

Sensitivity: Internal

12

Diagrams: Structural: Component Diagram

Component diagrams represent a set of components and their relationships. These components consist of classes, interfaces or collaborations.

So Component diagrams represent the implementation view of a system.

During design phase software artefacts (classes, interfaces etc) of a system are arranged in different groups depending upon their relationship. These groups are known as components.

Finally, component diagrams are used to visualise the implementation

www.derby.ac.uk/engtech

Sensitivity: Internal

13

Sample Component Diagram

www.derby.ac.uk/engtech

Sensitivity: Internal

14

Diagrams: Structural: Deployment Diagram

Deployment diagrams are a set of nodes and their relationships. These nodes are physical entities where the components are deployed.

Deployment diagrams are used for visualising deployment view of a system. This is generally used by the deployment team.

www.derby.ac.uk/engtech

Sensitivity: Internal

15

Sample Deployment Diagram

www.derby.ac.uk/engtech

Sensitivity: Internal

16

Diagrams: Behavioural: Use case Diagram

Use case diagrams are a set of use cases, actors and their relationships. They represent the use case view of a system.

A use case represents a particular functionality of a system.

So use case diagram is used to describe the relationships among the functionalities and their internal/external controllers. These controllers are known as actors.

www.derby.ac.uk/engtech

Sensitivity: Internal

17

Sample Use Case Diagram

www.derby.ac.uk/engtech

Sensitivity: Internal

18

Diagrams: Behavioural: Sequence Diagram

A sequence diagram is an interaction diagram. The name indicates that the diagram deals with sequences, which are the sequence of messages flowing from one object to another.

Interaction among the components of a system is very important from implementation and execution perspective.

Sequence diagram is used to visualize the sequence of calls in a system to perform a specific functionality.

www.derby.ac.uk/engtech

Sensitivity: Internal

19

Sample Sequence Diagram

www.derby.ac.uk/engtech

Sensitivity: Internal

20

Diagrams: Behavioural: Collaboration Diagram

Collaboration diagram is another form of interaction diagram. It represents the structural organisation of a system and the messages sent/received. Structural organisation consists of objects and links.

The purpose of collaboration diagram is similar to the sequence diagram, but the specific purpose of collaboration diagram is to visualise the organisation of objects and their interaction.

www.derby.ac.uk/engtech

Sensitivity: Internal

21

Sample Collaboration Diagram

www.derby.ac.uk/engtech

Sensitivity: Internal

22

Diagrams: Behavioural: Statechart Diagram

Any real time system is expected to be influenced by internal/external events. These events are responsible for state change of the system.

Statechart diagram is used to represent the event driven state change of a system. It describes the state change of a class, interface etc.

State chart diagram is used to visualise the reaction of a system by internal/external factors.

www.derby.ac.uk/engtech

Sensitivity: Internal

23

Sample Statechart Diagram

www.derby.ac.uk/engtech

Sensitivity: Internal

24

Diagrams: Behavioural: Activity Diagram

Activity diagram describes the flow of control in a system. So it consists of activities and links. The flow can be sequential, concurrent or branched.

Activities are the functions of a system. Numbers of activity diagrams are prepared to capture the entire flow in a system.

Activity diagrams are used to visualise the flow of controls in a system. This is prepared to have an idea of how the system will work when executed.

www.derby.ac.uk/engtech

Sensitivity: Internal

25

Sample Activity Diagram

www.derby.ac.uk/engtech

Sensitivity: Internal

26

Diagram commonality:

It should be clear that the diagrams have some relationship with one another.

e.g. Component diagrams depend on classes, interfaces etc. which are part of class/object diagram.

e.g. Deployment diagrams are dependent on components used to make component diagrams.

www.derby.ac.uk/engtech

Sensitivity: Internal

27

System logic in SAS

Pre-process (how you prepare your datasets)

Analysis

Post-Process (how you present your results)

www.derby.ac.uk/engtech

Sensitivity: Internal

28

Your MIS in SAS

www.derby.ac.uk/engtech

Sensitivity: Internal

29

www.derby.ac.uk/engtech

Sensitivity: Internal

30