Let SAS Help You Easily Find and Access Your Folders and Files

Similar documents
A Macro that can Search and Replace String in your SAS Programs

A Macro that can Search and Replace String in your SAS Programs

A Macro that Creates U.S Census Tracts Keyhole Markup Language Files for Google Map Use

A SAS Macro Utility to Modify and Validate RTF Outputs for Regional Analyses Jagan Mohan Achi, PPD, Austin, TX Joshua N. Winters, PPD, Rochester, NY

SAS Macros of Performing Look-Ahead and Look-Back Reads

Reading in Data Directly from Microsoft Word Questionnaire Forms

PROBLEM FORMULATION, PROPOSED METHOD AND DETAILED DESCRIPTION

A Tool to Compare Different Data Transfers Jun Wang, FMD K&L, Inc., Nanjing, China

Macro Method to use Google Maps and SAS to Geocode a Location by Name or Address

CC13 An Automatic Process to Compare Files. Simon Lin, Merck & Co., Inc., Rahway, NJ Huei-Ling Chen, Merck & Co., Inc., Rahway, NJ

A Macro to Create Program Inventory for Analysis Data Reviewer s Guide Xianhua (Allen) Zeng, PAREXEL International, Shanghai, China

Your Own SAS Macros Are as Powerful as You Are Ingenious

Using SAS to Control the Post Processing of Microsoft Documents Nat Wooding, J. Sargeant Reynolds Community College, Richmond, VA

Matt Downs and Heidi Christ-Schmidt Statistics Collaborative, Inc., Washington, D.C.

A Macro to Keep Titles and Footnotes in One Place

Top Coding Tips. Neil Merchant Technical Specialist - SAS

Using DDE with Microsoft Excel and SAS to Collect Data from Hundreds of Users

When Powerful SAS Meets PowerShell TM

Out of Control! A SAS Macro to Recalculate QC Statistics

Customizing a Multi-Cell Graph Created with SAS ODS Graphics Designer Yanhong Liu, Cincinnati Children s Hospital Medical Center, Cincinnati, OH

ABSTRACT: INTRODUCTION: WEB CRAWLER OVERVIEW: METHOD 1: WEB CRAWLER IN SAS DATA STEP CODE. Paper CC-17

A SAS Solution to Create a Weekly Format Susan Bakken, Aimia, Plymouth, MN

Using SAS to Control and Automate a Multi SAS Program Process Patrick Halpin, dunnhumby USA, Cincinnati, OH

The Ugliest Data I ve Ever Met

LST in Comparison Sanket Kale, Parexel International Inc., Durham, NC Sajin Johnny, Parexel International Inc., Durham, NC

Program Validation: Logging the Log

Automating Comparison of Multiple Datasets Sandeep Kottam, Remx IT, King of Prussia, PA

Data Quality Review for Missing Values and Outliers

The Output Bundle: A Solution for a Fully Documented Program Run

Syntax Conventions for SAS Programming Languages

Run your reports through that last loop to standardize the presentation attributes

Chaining Logic in One Data Step Libing Shi, Ginny Rego Blue Cross Blue Shield of Massachusetts, Boston, MA

3N Validation to Validate PROC COMPARE Output

A SAS Macro for Producing Benchmarks for Interpreting School Effect Sizes

A Picture Is Worth A Thousand Data Points - Increase Understanding by Mapping Data. Paul Ciarlariello, Sinclair Community College, Dayton, OH

Developing SAS Studio Repositories

PharmaSUG 2013 CC26 Automating the Labeling of X- Axis Sanjiv Ramalingam, Vertex Pharmaceuticals, Inc., Cambridge, MA

SAS Graphs in Small Multiples Andrea Wainwright-Zimmerman, Capital One, Richmond, VA

Using Dynamic Data Exchange

PharmaSUG Paper PO12

Reporting Template. By Denis Fafard Business Analyst WCB - Alberta

Automated Checking Of Multiple Files Kathyayini Tappeta, Percept Pharma Services, Bridgewater, NJ

How a Code-Checking Algorithm Can Prevent Errors

Validation Summary using SYSINFO

MISSING VALUES: Everything You Ever Wanted to Know

A Visual Step-by-step Approach to Converting an RTF File to an Excel File

A Generalized Macro-Based Data Reporting System to Produce Both HTML and Text Files

Procedure for Stamping Source File Information on SAS Output Elizabeth Molloy & Breda O'Connor, ICON Clinical Research

Virtual Accessing of a SAS Data Set Using OPEN, FETCH, and CLOSE Functions with %SYSFUNC and %DO Loops

Using a Control Dataset to Manage Production Compiled Macro Library Curtis E. Reid, Bureau of Labor Statistics, Washington, DC

A Lazy Programmer s Macro for Descriptive Statistics Tables

SAS Drug Development Program Portability

Bryan K. Beverly, UTA/DigitalNet

Perceptive Process Mining

Submitting SAS Code On The Side

What to Expect When You Need to Make a Data Delivery... Helpful Tips and Techniques

Data Edit-checks Integration using ODS Tagset Niraj J. Pandya, Element Technologies Inc., NJ Vinodh Paida, Impressive Systems Inc.

Using a Fillable PDF together with SAS for Questionnaire Data Donald Evans, US Department of the Treasury

The Demystification of a Great Deal of Files

Text Generational Data Sets (Text GDS)

INTRODUCTION THE FILENAME STATEMENT CAPTURING THE PROGRAM CODE

ABSTRACT INTRODUCTION THE ODS TAGSET FACILITY

Essential ODS Techniques for Creating Reports in PDF Patrick Thornton, SRI International, Menlo Park, CA

PDF Multi-Level Bookmarks via SAS

SAS USER FORUM NORWAY 2017 USER FORUM. Show Off Your OAuth Authenticating to Web Services in SAS

A Format to Make the _TYPE_ Field of PROC MEANS Easier to Interpret Matt Pettis, Thomson West, Eagan, MN

Using PROC REPORT to Cross-Tabulate Multiple Response Items Patrick Thornton, SRI International, Menlo Park, CA

TLF Management Tools: SAS programs to help in managing large number of TLFs. Eduard Joseph Siquioco, PPD, Manila, Philippines

SAS Macro Technique for Embedding and Using Metadata in Web Pages. DataCeutics, Inc., Pottstown, PA

SAS Data Integration Studio Take Control with Conditional & Looping Transformations

Useful Tips When Deploying SAS Code in a Production Environment

A Table Driven ODS Macro Diane E. Brown, exponential Systems, Indianapolis, IN

Cover the Basics, Tool for structuring data checking with SAS Ole Zester, Novo Nordisk, Denmark

Missing Pages Report. David Gray, PPD, Austin, TX Zhuo Chen, PPD, Austin, TX

. Click on the File Sharing link to access File Sharing..

To conceptualize the process, the table below shows the highly correlated covariates in descending order of their R statistic.

Producing Summary Tables in SAS Enterprise Guide

Implementing external file processing with no record delimiter via a metadata-driven approach

SD10 A SAS MACRO FOR PERFORMING BACKWARD SELECTION IN PROC SURVEYREG

While You Were Sleeping, SAS Was Hard At Work Andrea Wainwright-Zimmerman, Capital One Financial, Inc., Richmond, VA

ABSTRACT MORE THAN SYNTAX ORGANIZE YOUR WORK THE SAS ENTERPRISE GUIDE PROJECT. Paper 50-30

Sending SAS Data Sets and Output to Microsoft Excel

Correcting for natural time lag bias in non-participants in pre-post intervention evaluation studies

Ranking Between the Lines

A Mass Symphony: Directing the Program Logs, Lists, and Outputs

External Files. Definition CHAPTER 38

How to Keep Multiple Formats in One Variable after Transpose Mindy Wang

Edit the Editor: Creating Keyboard Macros in SAS Enterprise Guide

SAS ENTERPRISE GUIDE USER INTERFACE

Using SAS/GRAPH Software to Create Graphs on the Web Himesh Patel, SAS Institute Inc., Cary, NC Revised by David Caira, SAS Institute Inc.

Clinical Data Visualization using TIBCO Spotfire and SAS

ABSTRACT INTRODUCTION MACRO. Paper RF

Abstract. Background. Summary of method. Using SAS to determine file and space usage in UNIX. Title: Mike Montgomery [MIS Manager, MTN (South Africa)]

PharmaSUG China Paper 059

Creating Zillions of Labels (and Other Documents) the Easy Way with ODS and Microsoft Word

Fly over, drill down, and explore

Congratulations. EPG Workshop

FILE SHARING OVERVIEW HOW DO I ACCESS FILE SHARING? NAVIGATION

How to use UNIX commands in SAS code to read SAS logs

ODS/RTF Pagination Revisit

Transcription:

Paper 11720-2016 Let SAS Help You Easily Find and Access Your Folders and Files ABSTRACT Ting Sa, Cincinnati Children s Hospital Medical Center In this paper, a SAS macro is introduced that can help users find and access their folders and files very easily. By providing a path to the macro and letting the macro know which folders and files you are looking for under this path, the macro creates an HTML report that lists the matched folders and files. The best part of this HTML report is that it also creates a hyperlink for each folder and file so that when a user clicks the hyperlink, it directly opens the folder or file. Users can also ask the macro to find certain folders or files by providing part of the folder or file name as the search criterion. The results shown in the report can be sorted in different ways so that it can further help users quickly find and access their folders and files. INTRODUCTION Below are the screenshots for a sample html report. Figure1 lists all the files and folders under directory C:\generate_html. The report in figure 1 is sorted by Location column. Figure 1. the Screenshot for a Sample HTML File Report 1

If you only want to select all the folders or select all the jpg files inside the folder C:\generate_html or find a file whose name is test.pdf, the macro can help you do those things as well. See the screenshots in Figure2, 3 and 4. Figure 2. Find the Folders inside the C:\generate_html Folder Figure 3. Find the JPG Files inside the C:\generate_html Folder Figure 4. Find the Test.pdf File inside the C:\generate_html Folder Also you can sort the listings using different ways. Figure 5 is the screenshot that sorting the results by the descending modified date. Figure 5. Find all the HTML Files inside the C:\generate_html Folder and Sort the Results by Descending Modified Date If you click the name of the folder or the file, the folder or the file will be opened directly. 2

THE FINDFILES MACRO Presented below are the SAS codes for the Findfiles macro: %macro Findfiles(dirnm=,outhtml=,filetype=%str(),sortvars=%str(), browser_type=iexplore); filename DIRLIST pipe "dir /-c /q /s /t:w ""&dirnm""" ; data tmp1; length path filename $255 line $1024 owner $17 temp $16; retain path; infile DIRLIST length=reclen; input line $varying1024. reclen; if reclen = 0 then delete ; if scan(line,1," ")='Volume' or scan(line,1," ")='Total' or scan(line,2," ")='File(s)' or scan(line,2," ")='Dir(s)' then delete ; dir_rec=upcase(scan(line,1," "))='DIRECTORY'; if dir_rec then path=left(substr(line,length("directory of")+2)); else do; date=input(scan(line,1," "),mmddyy10.); time=input(scan(line,2," "),time5.); post_meridian=(scan(line,3," ")='PM'); if post_meridian then time=time+'12:00:00't ; temp = scan(line,4," "); if temp='<dir>' then size=0; else size=input(temp,best.) ; owner=scan(line,5," "); filename=scan(line,6," "); if filename in ('.' '..') then delete; ndx=index(line,scan(filename,1)); filename=substr(line,ndx); end; run; data tmp2; set tmp1; length Type $20.; if index(filename,".")=0 then Type="Folder"; else Type=propcase(scan(filename,2,".")); if filename ^="" then src=cats(path,"\",filename); 3

else src=path; location=cats("<a href='",src,"'>",src,"</a><br>"); date_modified=catx(" ",put(date,yymmdd10.),put(time,time5.)); %if &filetype NE %str() %then %do; if index(upcase(filename),upcase("&filetype."))>0 or index(upcase(type),upcase("&filetype."))>0; keep Type location date_modified; label location="location" date_modified="date Modified"; run; data tmp2; set tmp2; if index(lowcase(location),"service")>0 then delete; run; proc sort data=tmp2 nodupkey;by Location;run; %if &sortvars NE %str() %then %do; proc sort data=tmp2;by &sortvars.;run; ods html file="&outhtml."; proc print data=tmp2 noobs label;run; ods html close; options NOXWAIT NOXSYNC; %if &browser_type.=iexplore %then %do; x "start iexplore &outhtml."; %else %if &browser_type.=chrome %then %do; %let newhtml=%sysfunc(tranwrd(&outhtml.,\,//)); x "start &browser_type. file://&newhtml."; %mend; The dirnm is used to indicate the directory you want the macro to search for files and folders. The outhtml is used to indicate the location and the filename for the output html report. 4

The filetype is used to indicate the type of the files you want to find, you can pass any values that are available for the column Type on the output html report. For e.g, if you want to find the folders, you can pass folder to the filetype parameter. The parameter filetype value is case-insensitive. By default, if you don t pass any value to it, it will list all the folders and files. The Sortvars is used to indicate how you want to sort your results. To sort the results by column Type, pass type value to the macro variable Sortvars. To sort the results by column Location, pass location value to the macro variable Sortvars. To sort the results by column Date Modified, pass date_modified value to the macro variable Sortvars. For example, if you want to sort the results by type and descending modified date, you can pass type descending modified_date to the sortvars macro parameter. By default, if you don t pass any value to it, it will sort the results by location. The browser_type is used to indicate which browser you want to use to open your html report. By default, it will use the internet explorer to open the report. You can also pass chrome to it to open the file in Google Chrome. CALL THE MACRO Below are some examples showing you how to call the macro to find different files and sort the results. 1. To Find all the files and folders inside the C:\generate_html folder and sort the results by type and descending modified date. The result will be saved into the result.html file on the C: drive. and Google Chrome will be used to open the report. You can call the macro in this way: %Findfiles(dirnm=%str(C:\generate_html),sortvars=%str(type descending date_modified),outhtml=%str(c:\result.html),browser_type=chrome); 2. To find all the html files inside the C:\generate_html folder and sort the results by location and type. The result will be saved into the C:\result.html file and the file will be opened by internet explorer by default. You can call the macro in this way: %Findfiles(dirnm=%str(C:\generate_html),filetype=%str(.html),sortvars=%str (location type),outhtml=%str(c:\result.html)); 3. To find the test.pdf file inside the C:\generate_html folder, you can call the macro in this way: %Findfiles(dirnm=%str(C:\generate_html),filetype=%str(test.pdf), outhtml=%str(c:\result.html)); 4. To find the folders inside the C:\generate_html folder, you can call the macro in this way: %Findfiles(dirnm=%str(C:\generate_html),filetype=%str(folder), outhtml=%str(c:\result.html)); CONCLUSION The macro presented in this paper can be used as a helpful tool to help users to access and manage their files and folders. Also the macro can be further extended to have more functions, like adding more information to the report, selecting those read only files or adding more functions or styles to the html report. 5

ACKNOWLEDGMENTS The author wishes to thank the Division of Biostatistics and Epidemiology at Cincinnati Children's Hospital Medical Center for its support. CONTACT INFORMATION Your comments and questions are valued and encouraged. Contact the author at: Ting Sa Division of Biostatistics and Epidemiology Cincinnati Children s Hospital Medical Center 3333 Burnet Ave. Cincinnati, OH 45229 (513) 636-3674 E-mail: Ting.Sa@cchmc.org 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 trademarks of their respective companies. 6