6 - Life Science Analytics Framework Programming - Lesson 3
6 - Life Science Analytics Framework Programming - Lesson 3
Topics
3.1 Setup/Config Programs .......................................................................................................... 3-3
Copyright © 2022, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED.
3.1 Setup/Config Programs 3-3
Setup/Config R Programs
• Setup programs are used to make R code more portable from one project
to another. Typically, a setup file is included in every program within a
project so that there is consistency across the project. The setup file can
contain references to R data frames, R global variables, paths, and so on.
• To call a setup file into a Life Science Analytics Framework program (or any
other file), the programmer needs to use the special global variable
LSAF_WS pasted to the absolute path of the file.
Example: source(paste(LSAF_WS,"/Test area/R-code/paths.R",sep=""))
• A setup file can be used in Life Science Analytics Framework and can
facilitate the use of relative path programming.
4
Copyr i ght © SAS I nsti tute I nc. Al l r i ghts reser ved.
Copyright © 2022, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED.
3-4 Lesson 3 Advanced Programming Topics
This concept can be extended to allow for modifications in the hierarchy structure.
Even if the hierarchy structure changes, the SAS program might not need to be modified.
6
Copyr i ght © SAS I nsti tute I nc. Al l r i ghts reser ved.
7
Copyr i ght © SAS I nsti tute I nc. Al l r i ghts reser ved.
Copyright © 2022, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED.
3.2 Relative Paths 3-5
8
Copyr i ght © SAS I nsti tute I nc. Al l r i ghts reser ved.
This concept can be extended to allow for modifications in the hierarchy structure.
Even if the hierarchy structure changes, the R program
9 might not need to be modified.
Copyr i ght © SAS I nsti tute I nc. Al l r i ghts reser ved.
Copyright © 2022, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED.
3-6 Lesson 3 Advanced Programming Topics
10
Copyr i ght © SAS I nsti tute I nc. Al l r i ghts reser ved.
Copyright © 2022, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED.
3.2 Relative Paths 3-7
Best Practice: A config (or setup) file can be changed if the hierarchy
changes. Programs are not changed and do not need to be revalidated.
This is based on a dynamic base path.
12
Copyr i ght © SAS I nsti tute I nc. Al l r i ghts reser ved.
Copyright © 2022, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED.
3-8 Lesson 3 Advanced Programming Topics
3.3 Sessions
Sessions
The Sessions panel is used to keep track of SAS and/or R sessions that exist
in the application. It is accessed by clicking Sessions on the navigation bar.
The Show Query Builder icon toggles between showing and hiding the query
parameters for the Session panel.
The Manage All Sessions privilege allows a user to see all the sessions owned
by all users. The Sessions panel shows if there are jobs not finishing, if there are
excessive sessions opened by a user, and any ended sessions that are not able
to publish final results to repository.
14
Copyr i ght © SAS I nsti tute I nc. Al l r i ghts reser ved.
Session Types
Type of Sessions Example
Published jobs Any repository job
Session editor (SAS or R) Programs, logs (listings, data sets for SAS)
System sessions Data Standards and Study Management jobs
Workspace jobs Any workspace job
Test jobs Any workspace job runs with Test job option
15
Copyr i ght © SAS I nsti tute I nc. Al l r i ghts reser ved.
Copyright © 2022, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED.
3.3 Sessions 3-9
Session States
State of Sessions Description Notes
Broken ( ) shows that there is a disconnection This rarely happens. When it does, it is usually due to some sort of network
from the SAS or R Server. issue. 16
Copyr i ght © SAS I nsti tute I nc. Al l r i ghts reser ved.
Sessions
• If a user does not have the Create Sessions privilege or the Manage Sessions
privilege, all programs and SAS data sets open only in the File Viewer.
• Initially, the query builder is visible. Users can query what types of sessions they
want to look for on the left side of the window. They can toggle the Hide/Show
Query Builder icon to show or hide the Query Parameters panel.
• When querying sessions, the Manage All Sessions privilege enables the user
to choose other sessions to review.
• Selecting a different user’s session opens the Details tab.
• Selecting the user’s own session opens that session with all included items
(details, results, logs, data sets, and programs).
17
Copyr i ght © SAS I nsti tute I nc. Al l r i ghts reser ved.
Copyright © 2022, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED.
3-10 Lesson 3 Advanced Programming Topics
Sessions
• To start a new session, click the New Editor icon in the upper right corner. If a user
is already in a session, then the user can click the View Sessions icon and start a new
editor session.
• Each session is independent of all the others.
Note: Multiple programs opened within a single session share the session resources
(for example, the Work library).
• The Opened Items icon in the upper right corner informs the user how many sessions are
currently open and gives the user the option to close all of the items or individual sessions.
• The default is to have polling on (automatic refresh). This feature enables the user to refresh
the sessions that can be viewed based on the last query that was requested. A refresh is
automatically done approximately every five seconds. A user can toggle between
Disable/Enable automatic refresh using the icon. Disabling the automatic refresh enables
the user to manually choose when to run the query to view the sessions available. This gives
users more control of what they want to see.
Note: Disabling this feature lasts for only the active session.
18
Copyr i ght © SAS I nsti tute I nc. Al l r i ghts reser ved.
Sessions
• A user can end a session by clicking the End/Disconnect icon .
A user might want to end a session because of a non-ending job or an
interactive session with an infinite loop. (You need to terminate but want
to review the log.) Sessions that are ended go into ended state.
• A user can reconnect only to a session that the user started. When
this is done in an interactive session, it refreshes the session.
• Only the interactive session goes away when the browser times out.
A user activity (edits and so on) within the session keeps the browser
session active.
• A user can also end a session by clicking the Delete icon . This
removes or closes the session. If there are unsaved changes, a message
appears noting this.
19
Copyr i ght © SAS I nsti tute I nc. Al l r i ghts reser ved.
Copyright © 2022, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED.
3.4 Job of Jobs 3-11
Job of Jobs
• Job of Jobs
• Calling one or more jobs from another job
• A caller job is referred to as a parent job, whereas a job being called is referred
to as a child job.
• Can retrieve a list of job parameters for each child job, update the values, and
submit the job with run-time values.
21
Copyr i ght © SAS I nsti tute I nc. Al l r i ghts reser ved.
Job of Jobs
Child Program
• Main logic resides in the child program.
Child Job
• Defines parameters for any dynamic inputs or outputs.
• References one or more child programs.
Parent Program
• Identifies the list of objects for which specific child logic is to be repeated.
• Retrieves the list of parameters defined on the child job.
• Executes the child job n times by passing different run-time values for the child job
parameters.
Parent Job
• References the parent program.
22
Copyr i ght © SAS I nsti tute I nc. Al l r i ghts reser ved.
Copyright © 2022, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED.
3-12 Lesson 3 Advanced Programming Topics
• The Life Science Analytics Framework macros enable you to use familiar
SAS syntax to make calls to Life Science Analytics Framework to perform
certain operations such as retrieving directory contents and its metadata
or managing users.
• SAS API macros can run from within Life Science Analytics Framework,
from a SAS server, or from local PC SAS.
24
Copyr i ght © SAS I nsti tute I nc. Al l r i ghts reser ved.
Copyright © 2022, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED.
3.5 SAS API Macros 3-13
Copyright © 2022, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED.
3-14 Lesson 3 Advanced Programming Topics
29
Copyr i ght © SAS I nsti tute I nc. Al l r i ghts reser ved.
Copyright © 2022, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED.
3.6 Best Practices 3-15
30
Copyr i ght © SAS I nsti tute I nc. Al l r i ghts reser ved.
Copyright © 2022, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED.
3-16 Lesson 3 Advanced Programming Topics
• When you are testing a job in the user workspace, copy only those files
from the content repository that are required for the job to run
successfully.
Avoid synching complete folder structures to the user workspace unless
required because this results in unnecessary space consumption.
32
Copyr i ght © SAS I nsti tute I nc. Al l r i ghts reser ved.
Copyright © 2022, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED.
3.6 Best Practices 3-17
From Publish History, the publish (check-in) step can be retried after troubleshooting problems
with the job, or the associated SAS session can be deleted, which also clears the transient
workspace.
35
Copyr i ght © SAS I nsti tute I nc. Al l r i ghts reser ved.
Copyright © 2022, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED.
3-18 Lesson 3 Advanced Programming Topics
3. A setup file does not support the work with relative paths.
37
Copyr i ght © SAS I nsti tute I nc. Al l r i ghts reser ved.
3. A setup file does not support the work with relative paths. False.
The setup file can be included via a relative path and have relative
paths defined in it. 38
Copyr i ght © SAS I nsti tute I nc. Al l r i ghts reser ved.
Copyright © 2022, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED.
3.7 Lesson Quiz 3-19
39
Copyr i ght © SAS I nsti tute I nc. Al l r i ghts reser ved.
40
Copyr i ght © SAS I nsti tute I nc. Al l r i ghts reser ved.
Copyright © 2022, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED.
3-20 Lesson 3 Advanced Programming Topics
2. True/False: Users query the types of sessions they want to review by toggling the Hide/Show Query Builder
icon.
4. Which of the follow is not a session type in Life Science Analytics Framework?
a. published jobs
b. SAS programs
c. system sessions
d. workspace jobs
e. audit trail processing
2. True/False: Users query the types of sessions they want to review by toggling the Hide/Show Query Builder
icon. True
3. True/False: A session state can be Active, Broken, Ended, Ending, or Idle. True
4. Which of the follow is not a session type in Life Science Analytics Framework?
a. published jobs
b. SAS programs
c. system sessions
d. workspace jobs
e. audit trail processing
Copyright © 2022, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED.
3.7 Lesson Quiz 3-21
2. In the Job of Jobs concept, repetitive task logic should be written in the
child job.
3. For the Job of Jobs concept, all jobs run in one SAS session.
43
Copyr i ght © SAS I nsti tute I nc. Al l r i ghts reser ved.
2. In the Job of Jobs concept, repetitive task logic should be written in the
child job. True
3. For the Job of Jobs concept, all jobs run in one SAS session. False.
There is one session for the parent job, and one session is created
for each child job execution.
44
Copyr i ght © SAS I nsti tute I nc. Al l r i ghts reser ved.
Copyright © 2022, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED.
3-22 Lesson 3 Advanced Programming Topics
2. Name three functions that can be done using SAS API macros.
45
Copyr i ght © SAS I nsti tute I nc. Al l r i ghts reser ved.
2. Name three functions that can be done using SAS API macros.
Functions include User Management, Context Management, Member
Management, Group Management, Role Management, File Management,
Permissions (ACLs), Recycle Bin Management, Synchronization of Repository
to Workspace
Copyright © 2022, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED.
3.7 Lesson Quiz 3-23
2. What is an advantage to using Run and populate while defining, running, and
testing a job in the Life Science Analytics Framework user workspace?
3. True/False: All programs and jobs should be tested from the Life Science
Analytics Framework user workspace before running them in the content
repository.
47
Copyr i ght © SAS I nsti tute I nc. Al l r i ghts reser ved.
Copyright © 2022, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED.
3-24 Lesson 3 Advanced Programming Topics
2. True/False: If a job has check-in (publish) errors and is deleted from the Life
Science Analytics Framework repository, files remain orphaned in the transient
workspace.
49
Copyr i ght © SAS I nsti tute I nc. Al l r i ghts reser ved.
2. True/False: If a job has check-in (publish) errors and is deleted from the Life
Science Analytics Framework repository, files remain orphaned in the transient
workspace. True
3. Bonus: Why is this an issue? The transient workspace is a shared physical file
system, and orphaned content consumes that shared space.
50
Copyr i ght © SAS I nsti tute I nc. Al l r i ghts reser ved.
Copyright © 2022, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED.