Title: Using SYSTASK to dynamically create LIBNAME statements
1Using SYSTASK to dynamically create LIBNAME
statements
- Ray Cloutier
- Health Dialog
2Introduction
- How to dynamically create LIBNAME statements
3Consistent Directory Structure
- Facilitates cross project analysis
- Enables team work
- Keeps things tighty
4Sample Folder Structure
5Declare Macro
macro project_analysis(working_folder ,
projects_folder )
6Use SYSTASK to create a text file listing of
projects
systask command "ls projects_folder. gt
working_folder.all_project_folders.txt"
shell tasknameget_project_paths waitfor
get_project_paths
7Read in the list of projects
data project_folders length project_folder
32 infile "working_folder.all_project_folder
s.txt" lrecl200 termstrcrlf input
_at_1 project_folder 32. run
8Create a macro variable containing the list of
projects
proc sql noprint select project_folder
into projects_list
separated by ' from
project_folders quit put list of
projects projects_list
9Parse the list of projects
let p1 / used as a counter variable. / do
while (scan(projects_list,p,str()) ne
str( )) let current_project
scan(projects_list,p,str()) put project
current_project
10Perform a task for each project
/ ---- place task to perform for each here
---/ libname whp. "projects_folder.current_p
roject./data"
accessreadonly / ----------- end task
work -----------------/
11Increment Counter end loop
let peval(p1) /increment the counter
/ end mend project_analysis project
_analysis (working_folder
/tmp/sandbox/projects ,projects_folder
/projects/)
12Conclusion
- Consistency can have great benefits
- Find a folder structure that works for your
projects - Avoid kitchen counter (catch all) folders!
13SAS blurb slide
- SAS and all other SAS Institute Inc. product
- or service names are registered trademarks or
- trademarks of SAS Institute Inc. in the USA
- and other countries. indicates USA
- registration. Other brand and product names
- are registered trademarks or trademarks of
- their respective companies.
14My Contact info
- Ray Cloutier
- Health Dialog
- rcloutier_at_healthdialog.com
15Using SYSTASK to Dynamically create LIBNAME
statements