In this paper, we will build the macro step-by-step, highlighting each function. A basic familiarity with SAS Macro language is assumed.
|
|
- Florence Harper
- 6 years ago
- Views:
Transcription
1 No More Split Ends: Outputting Multiple CSV Files and Keeping Related Records Together Gayle Springer, JHU Bloomberg School of Public Health, Baltimore, MD ABSTRACT The EXPORT Procedure allows us to output CSV files easily. For our application, we need to limit the number of records in our output CSV files. Using FIRSTOBS= and OBS= options in PROC EXPORT, we can manipulate the number of records in each file. Additionally, when we need to keep related records together in the output CSV file, we can manipulate the data in a DATA step and use the WHERE statement in PROC EXPORT to ensure the number of observations in each CSV file is not larger than our requirements and related data remains in the same CSV file. INTRODUCTION In our NIH-funded study, many different types of specimens are provided by study participants, including serum, plasma, and cervical-vaginal lavage, and placed in a central biorepository collection of over 2 million vials. This biorepository has an Internet-based data management system where we specify the vials to be shipped to labs for testing. The central biorepository has a limit of 300 vials per withdrawal requisition. If we have a larger number of vials to select, we must split the request into smaller batches containing no more than 300 vials. At times, we must also ensure that related vials are sent in the same requisition. The biorepository s system allows us to import comma-delimited files to help with specimen selection. We use the EXPORT procedure to copy our data from SAS data sets to CSV files. Before writing the data, we format dates, times and other values as needed in a DATA step so that the values display properly in the CSV file. In this paper, we will build the macro step-by-step, highlighting each function. A basic familiarity with SAS Macro language is assumed. EXPORTING A SAS DATA SET TO A CSV FILE The following syntax copies the SAS data set WORK.MYPROJECT to the CSV file myproject.ddmonyyyy.csv in the current directory. The REPLACE option tells SAS to overwrite the CSV file if it already exists. PROC EXPORT DATA= myproject OUTFILE = "myproject.&sysdate..csv" We can generalize this code by placing it in a simple macro, with the data set name to be provided as a macro parameter by the user. %MACRO makecsv (dsn); PROC EXPORT DATA= &dsn. OUTFILE = "&dsn..&sysdate..csv" %MEND makecsv; Assuming we have a specimen request of fewer than 300 vials, we can simply run the macro with this syntax: % makecsv(dsn=myproject) BREAKING THE SAS DATA SET INTO MULTIPLE CSV FILES When a specimen request contains more than 300 vials, we must create multiple CSV files, each with a maximum of 300 observations. In order to do this, we first determine the the number of observations in the data set. Then we can use options FIRSTOBS= and OBS= with PROC EXPORT to output all the needed CSV files. We begin by performing SAS functions on the [input] data set using the macro command %SYSFUNC. In lines (1)- (3), we determine the number of observations in the original data set In (1), the data set is opened. In (2), the number of observations is copied to the macro variable NUMOBS In (3), the data set is closed. 1
2 %MACRO makecsv (dsn) (1) %LET dsid=%sysfunc(open(&dsn)); (2) %LET numobs=%sysfunc(attrn(&dsid, NLOBS)); (3) %LET rc=%sysfunc(close(&dsid)); We continue by creating our output CSV files. Each iteration of the %DO loop copies 300 observations into separate output files numbered sequentially. In (5), we create a file number counter to use with our output CSV files. In (6)-(11), we use a %DO loop to create our output CSV files. In (6), the %DO loop will begin with the first observation and continue through the number of observations in the data set (&NUMOBS), incremented by the number of observations we want in our output data set. In (7), increment &K by one. In (8), use FIRSTOBS=&I to tell SAS the first observation to write to the file. The last record to be written is noted by OBS=(&I ) (8), where &I is the first observation to be written + the number of records to include in the data set, decreased by one. We need to subtract one from the OBS= option because our loop begins with the number one, e.g., beginning at obs = 1 would give us (300+1)=301 observations instead of the required 300 observations. In (9), the OUTFILE= filename includes our file counter macro variable &K. In (10), the DBMS= and REPLACE options are kept the same. (5) %LET k = 0; (6) %DO i = 1 %TO &numobs %BY 300 ; (7) %LET k = %EVAL(&k+1); (8) PROC EXPORT DATA=&dsn (FIRSTOBS=&i OBS=%eval(&i )) (9) OUTFILE = "batch&dsn&k..&sysdate..csv" (10) (11) * end of DO loop *; %MEND makecsv; CSV WITH USER-SPECIFIED NUMBER OF OBSERVATIONS We can make this macro more general by adding a macro parameter NVIALS that allows the number of observations in the output CSV file to be specified. In (1), the default value of 300 for NVIALS is specified. In (2), the %DO loop is incremented by NVIALS. In (3), the number of observations to be written is indicated by NVIALS. (1) %MACRO makecsv (dsn, nvials=300) * Determine number of records in &DSN *; %LET dsid=%sysfunc(open(&dsn)); %LET numobs=%sysfunc(attrn(&dsid, NLOBS)); %LET rc=%sysfunc(close(&dsid)); %LET k = 0; (2) %DO i = 1 %TO &numobs %BY &nvials ; %LET k = %EVAL(&k+1); (3) PROC EXPORT DATA=&dsn (FIRSTOBS=&i OBS=%EVAL(&i +&nvials -1)) OUTFILE = "batch&dsn&k..&sysdate..csv" %MEND makecsv; By providing the default value of 300 for NVIALS, the macro will function exactly as in the last step by calling with %makecsv(myproject). Alternatively, to call the macro and specify 250 records per output CSV file, use: % makecsv(dsn=myproject, nvials=250); KEEPING RELATED RECORDS (VIALS) TOGETHER IN A REQUEST Our next concern is keeping related vials together in the same withdrawal request. Note that this next extension of our macro will allow grouping of related specimen vials by the value (category) of a single or of multiple variables in the data set. To handle this, we add a macro parameter KEEPTOGETHER containing the variable(s) that identify related groups. This macro variable will be used in a BY statement that in effect defines these groups. In our example, we wish to keep all vials for a specific id together. 2
3 The steps we need to take are: 1) Determine the number of observations in each group of related vials. If our groups are determined by a single variable, the number of observations in each group is the frequency of each value of the variable. If our groups are determined by more than one variable, the number of observations in each group is the frequency of each distinct combination of the variables. 2) If &KEEPTOGETHER includes more than one variable, obtain the last variable in the list (i.e., in the BY statement) so it can be used with FIRST.<variable> statements. 3) Using the steps described previously, limit the output file to no more than 300 observations and ensure our grouped records remain together. Before showing the full macro, we will show an example of how the macro is invoked using our new macro variable KEEPTOGETHER. %makecsv(myproject, nvials = 300, keeptogether= caseno id); We sort the data set (1) by KEEPTOGETHER and use PROC MEANS to obtain the number of observations in each group (2), which is copied to the variable _COUNT in the data set _NIDS (3). (1) PROC SORT DATA=&dsn; BY &keeptogether; (2) PROC MEANS NOPRINT N DATA=&dsn; VAR &keeptogether ; (3) OUTPUT OUT = _nids (KEEP= &keeptogether _count) N=_count; Next, merge data set _NIDS with the original data set (4) by the variables in &KEEPTOGETHER (5). DATA _combine; (4) MERGE &dsn _nids ; (5) Set the combined data set by the &KEEPTOGETHER variables so that automatic variables FIRST.<variable> may be used during the count of observations (6,7) DATA &dsn.; (6) SET _combine ; (7) BY &keeptogether; For each group, we need to know the number of observations in the group to ensure that we do not exceed the maximum number of records in each file. To do this, we will capture the last variable in the &KEEPTOGETHER list for use later in the program. In (8), use the macro function %SCAN with a negative number as the second argument reads from the end of the string and searches backward. (8) %LET lastvar = %SCAN(&keeptogether, -1) ; Then, in a DATA step, create a variable (NEXTFILE) that will keep count of the number of sets of &VNAILS records, e.g., NEXTFILE=1 for the first set of &NVIALS records, NEXTFILE=2 for the second set of &NVIALS records, through NEXTFILE=n for the last set of records to be written to the output CSV file. In (9) and (10), SET the data set BY the &KEEPTOGETHER variables so automatic variable FIRST.<variable> may be used In (11), RETAIN _TOTAL and NEXTFILE so that their values are carried forward for each record. Variable _TOTAL will keep a running count of the total number of observations to be written to the output CSV file. In (12), increment _TOTAL by _COUNT at the beginning of each BY group. _COUNT, the number of observations in the &KEEPTOGETHER group, is repeated on all records within that BY group. Hence, _COUNT needs to be added to _TOTAL only once per group. In (13)-(16), when _TOTAL becomes larger than the number of observations specified in &NVIALS, reset the _total counter to _COUNT and change the value for NEXTFILE. In (14), _TOTAL is reset to _COUNT. In (15), increment NEXTFILE by one for the next set of &NVIALS observations to be written to a new CSV file. In (17), CALL SYMPUT is executed to assign the value of NEXTFILE to the macro parameter _MYLASTFILE. Although line 17 is executed with each record, the final value for _MYLASTFILE will be the value of NEXTFILE in the last observation of WORK._BATCH. In (18), write the value of &_MYLASTFILE to the SAS LOG 3
4 DATA _batch ; (9) SET &dsn. ; (10) BY &keeptogether. ; (11) RETAIN _total 0 nextfile 1 ; (12) IF FIRST.&lastvar. THEN _total = _total + _count; (13) IF _total > &nvials THEN DO; (14) _total = _count; (15) nextfile+1; (16) END; (17) CALL SYMPUT ( '_mylastfile', nextfile); (18) %PUT The number of files to be written is &_mylastfile= ; Now we get back to the heart of our previous versions of our macro. The number of records for each value of NEXTFILE was ensured above (lines 13-15) to be less than or equal to the value specified in &NVIALS. In our %DO loop, we are not counting the number of observations this time. Instead, the value of NEXTFILE may be used to indicate which records will be output to each CSV file. By using a WHERE statement in our procedure, we can output our files. In (19), assign the macro variable to run from 1 to the number of files to be written (&_MYLASTFILE) In (20), restrict the output CSV file to with a WHERE= statement specifying NEXTFILE = &K. The %DO loop is repeated until all files have been written. (19) %DO k = 1 %TO &_mylastfile. ; (20) PROC EXPORT DATA=_batch (WHERE= (nextfile = &k.)) OUTFILE = "batch&dsn.&k..&sysdate..csv" The parameters in the above macro allow the user to specify the data set name (&DSN), the maximum number of records in the output data set (&NVIALS), and the grouping variables (&KEEPTOGETHER). ADDING ERROR CHECKS If the data set does not exist or a variable has been misspelled, our macro will not work. We can make the application more robust by adding some error checks. In (1), we create the local macro variable &BAD that will be used to flag a macro parameter error. In (2), we write a message to the log indicating what check will be performed. In (3) (5), we write an error to the log and set &BAD to t(rue) if the data set is not found In (6) (9), we loop through the variables listed in KEEPTOGETHER, and verify that they exist. The variable check only occurs if (as verified in (8)) the data set exists. In (10) (11), we write an error message to the log and stop processing if the error flag (&BAD) has been turned on. Otherwise, we continue processing. %makecsv(dsn=myproject, nvials = 300, keeptogether= case id); (1) %LOCAL bad; * check if DSN exists *; (2) %PUT Check for DSN (&dsn) existence ; (3) %IF %SYSFUNC(EXIST(WORK.&dsn))=0 %THEN %DO; (4) %PUT ERROR: data set &dsn does not exist ; (5) %LET bad=t; * check if variables exists *; %PUT Check for keeptogether (&keeptogether.) existence ; %LET _vnum=1; (6) %DO %WHILE(%SCAN(&keeptogether., &_vnum., %STR( )) ne ); (7) %IF %SYSFUNC(EXIST(WORK.&dsn))=1 %THEN %DO; %LET dsnid = %SYSFUNC(OPEN(&dsn)) ; %LET varck = %SCAN(&keeptogether, &_vnum, %STR( )); %PUT Checking if &varck exists ; (8) %IF %SYSFUNC(VARNUM(&dsnid,&varck)) = 0 %THEN %DO; %PUT ERROR: Variable in KEEPTOGETHER &varck does not exist ; %LET bad=t; %LET rc=%sysfunc(close(&dsnid)); 4
5 %LET _vnum = %EVAL(&_vnum +1); (9) * end of do while loop *; (10) %IF &bad.=t %THEN %DO; %PUT Ending macro due to ERROR(S) listed above ; %GOTO bottom; (11) /* more macro code */ (12) %bottom: %MEND makecsv ; CONCLUSION Using PROC EXPORT, PROC MEANS and some basic DATA steps, we created a program that limits the number of records in each CSV file to a specified number and prevents related records from being split between files. The entire macro is shown in Appendix A. Additional options we could add to this macro include location of the output data set (directory), other output destinations as specified with DBMS in PROC EXPORT, and even choosing to output the information to the listing file using a PROC (e.g., PRINT, REPORT) instead of writing the data to a file. APPENDIX A: %MACRO makecsv (dsn, nvials = 300, keeptogether= ); %LOCAL bad; * check if DSN exists *; %PUT Check for DSN (&dsn) existence ; %IF %SYSFUNC(EXIST(WORK.&dsn))=0 %THEN %DO; %PUT ERROR: data set &dsn does not exist ; %LET bad=t; * check if variables exists *; %PUT Check for keeptogether (&keeptogether.) existence ; %LET _vnum=1; %DO %WHILE(%SCAN(&keeptogether., &_vnum., %STR( )) ne ); %IF %SYSFUNC(EXIST(WORK.&dsn))=1 %THEN %DO; %LET dsnid = %SYSFUNC(OPEN(&dsn)) ; %LET varck = %SCAN(&keeptogether, &_vnum, %STR( )); %PUT Checking if &varck exists ; %IF %SYSFUNC(VARNUM(&dsnid,&varck)) = 0 %THEN %DO; %PUT ERROR: Variable in KEEPTOGETHER &varck does not exist ; %LET bad=t; %LET rc=%sysfunc(close(&dsnid)); %LET _vnum = %EVAL(&_vnum +1); * end of do while loop *; %IF &bad.=t %THEN %DO; %PUT Ending macro due to ERROR(S) listed above ; %GOTO bottom; %IF &KEEPTOGETHER = %THEN %DO; * Determine number of records in &DSN *; %LET dsid=%sysfunc(open(&dsn)); %LET numobs=%sysfunc(attrn(&dsid, NLOBS)); %LET rc=%sysfunc(close(&dsid)); %LET k = 0; %DO i = 1 %TO &numobs %BY &nvials ; %LET k = %EVAL(&k+1); PROC EXPORT DATA=&dsn (FIRSTOBS=&i OBS=%eval(&i +&nvials -1)) OUTFILE = "batch&dsn&k..&sysdate..csv" %END ; 5
6 /* end of writing files without KEEPTOGETHER variables */ %ELSE %DO; PROC SORT DATA=&dsn; BY &keeptogether; PROC MEANS NOPRINT N DATA=&dsn; VAR &keeptogether ; OUTPUT OUT = _nids (KEEP= &keeptogether _count) N=_count; DATA _combine; MERGE &dsn (IN=a) _nids ; IF a; DATA &dsn.; SET _combine ; BY &keeptogether; %LET lastvar = %SCAN(&keeptogether, -1) ; %PUT &lastvar is the last variable in keeptogether (&keeptogether). ; DATA _batch ; SET &dsn ; RETAIN _total 0 nextfile 1 ; IF FIRST.&lastvar THEN _total = _total + _count; IF _total > &nvials THEN DO; _total = _count; nextfile+1; END; CALL SYMPUT ( '_mylastfile', nextfile); %PUT The number of files to be written is &_mylastfile ; %DO k = 1 %TO &_mylastfile ; PROC EXPORT DATA=_batch (WHERE= (nextfile = &k)) OUTFILE = "batch&dsn&k..&sysdate..csv" %bottom: %MEND makecsv ; ACKNOWLEDGMENTS 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. Data in this manuscript were collected by the Women's Interagency HIV Study (WIHS) Collaborative Study Group with centers (Principal Investigators) at New York City/Bronx Consortium (Kathryn Anastos); Brooklyn, NY (Howard Minkoff); Washington DC, Metropolitan Consortium (Mary Young); The Connie Wofsy Study Consortium of Northern California (Ruth Greenblatt); Los Angeles County/Southern California Consortium (Alexandra Levine); Chicago Consortium (Mardge Cohen); Data Coordinating Center (Stephen Gange). The WIHS is funded by the National Institute of Allergy and Infectious Diseases (UO1-AI-35004, UO1-AI-31834, UO1-AI-34994, UO1-AI-34989, UO1-AI-34993, and UO1-AI-42590) and by the Eunice Kennedy Shriver National Institute of Child Health and Human Development (UO1-HD-32632). The study is co- funded by the National Cancer Institute, the National Institute on Drug Abuse, and the National Institute on Deafness and Other Communication Disorders. Funding is also provided by the National Center for Research Resources (UCSF-CTSI Grant Number UL1 RR024131). The contents of this publication are solely the responsibility of the authors and do not necessarily represent the official views of the National Institutes of Health. Special thanks to Bruce Gilsen, Johanna Goderre, and Jonathan Kerman for reviewing my drafts and providing constructive feedback. 6
7 I would also like to thank the many talented individuals whose written and presented work has helped me with my SAS programming. I cannot recall all the papers I referenced while creating this program, but I owe you all a big debt. CONTACT INFORMATION Your comments and questions are valued and encouraged. Contact the author at: Gayle Springer Johns Hopkins University Bloomberg School of Public Health 111 Market Street, Suite 906 Baltimore, MD fax gspringe@jhsph.edu 7
An Easy Route to a Missing Data Report with ODS+PROC FREQ+A Data Step Mike Zdeb, FSL, University at Albany School of Public Health, Rensselaer, NY
SESUG 2016 Paper BB-170 An Easy Route to a Missing Data Report with ODS+PROC FREQ+A Data Step Mike Zdeb, FSL, University at Albany School of Public Health, Rensselaer, NY ABSTRACT A first step in analyzing
More informationSD10 A SAS MACRO FOR PERFORMING BACKWARD SELECTION IN PROC SURVEYREG
Paper SD10 A SAS MACRO FOR PERFORMING BACKWARD SELECTION IN PROC SURVEYREG Qixuan Chen, University of Michigan, Ann Arbor, MI Brenda Gillespie, University of Michigan, Ann Arbor, MI ABSTRACT This paper
More informationA Simple Framework for Sequentially Processing Hierarchical Data Sets for Large Surveys
A Simple Framework for Sequentially Processing Hierarchical Data Sets for Large Surveys Richard L. Downs, Jr. and Pura A. Peréz U.S. Bureau of the Census, Washington, D.C. ABSTRACT This paper explains
More informationSubmitting SAS Code On The Side
ABSTRACT PharmaSUG 2013 - Paper AD24-SAS Submitting SAS Code On The Side Rick Langston, SAS Institute Inc., Cary NC This paper explains the new DOSUBL function and how it can submit SAS code to run "on
More informationPharmaSUG 2018 Paper AD-08 Parallel Processing Your Way to Faster Software and a Big Fat Bonus: Demonstrations in Base SAS. Troy Martin Hughes
PharmaSUG 2018 Paper AD-08 Parallel Processing Your Way to Faster Software and a Big Fat Bonus: Demonstrations in Base SAS ABSTRACT Troy Martin Hughes SAS software and especially extract-transform-load
More informationIdentifying Duplicate Variables in a SAS Data Set
Paper 1654-2018 Identifying Duplicate Variables in a SAS Data Set Bruce Gilsen, Federal Reserve Board, Washington, DC ABSTRACT In the big data era, removing duplicate data from a data set can reduce disk
More informationUsing PROC REPORT to Cross-Tabulate Multiple Response Items Patrick Thornton, SRI International, Menlo Park, CA
Using PROC REPORT to Cross-Tabulate Multiple Response Items Patrick Thornton, SRI International, Menlo Park, CA ABSTRACT This paper describes for an intermediate SAS user the use of PROC REPORT to create
More informationTales from the Help Desk 6: Solutions to Common SAS Tasks
SESUG 2015 ABSTRACT Paper BB-72 Tales from the Help Desk 6: Solutions to Common SAS Tasks Bruce Gilsen, Federal Reserve Board, Washington, DC In 30 years as a SAS consultant at the Federal Reserve Board,
More informationIf You Need These OBS and These VARS, Then Drop IF, and Keep WHERE Jay Iyengar, Data Systems Consultants LLC
Paper 2417-2018 If You Need These OBS and These VARS, Then Drop IF, and Keep WHERE Jay Iyengar, Data Systems Consultants LLC ABSTRACT Reading data effectively in the DATA step requires knowing the implications
More informationVirtual Accessing of a SAS Data Set Using OPEN, FETCH, and CLOSE Functions with %SYSFUNC and %DO Loops
Paper 8140-2016 Virtual Accessing of a SAS Data Set Using OPEN, FETCH, and CLOSE Functions with %SYSFUNC and %DO Loops Amarnath Vijayarangan, Emmes Services Pvt Ltd, India ABSTRACT One of the truths about
More informationBase and Advance SAS
Base and Advance SAS BASE SAS INTRODUCTION An Overview of the SAS System SAS Tasks Output produced by the SAS System SAS Tools (SAS Program - Data step and Proc step) A sample SAS program Exploring SAS
More informationSAS Macro Dynamics: from Simple Basics to Powerful Invocations Rick Andrews, Office of Research, Development, and Information, Baltimore, MD
ABSTRACT CODERS CORNER SAS Macro Dynamics: from Simple Basics to Powerful Invocations Rick Andrews, Office of Research, Development, and Information, Baltimore, MD The SAS Macro Facility offers a mechanism
More information1 Files to download. 3 Macro to list the highest and lowest N data values. 2 Reading in the example data file
1 2 22S:172 Lab session 10 Macros for data cleaning July 17, 2003 GENDER VISIT HR SBP DBP DX AE = "Gender" = "Visit Date" = "Heart Rate" = "Systolic Blood Pressure" = "Diastolic Blood Pressure" = "Diagnosis
More informationSAS Macro Dynamics - From Simple Basics to Powerful Invocations Rick Andrews, Office of the Actuary, CMS, Baltimore, MD
Paper BB-7 SAS Macro Dynamics - From Simple Basics to Powerful Invocations Rick Andrews, Office of the Actuary, CMS, Baltimore, MD ABSTRACT The SAS Macro Facility offers a mechanism for expanding and customizing
More informationChecking for Duplicates Wendi L. Wright
Checking for Duplicates Wendi L. Wright ABSTRACT This introductory level paper demonstrates a quick way to find duplicates in a dataset (with both simple and complex keys). It discusses what to do when
More informationUnlock SAS Code Automation with the Power of Macros
SESUG 2015 ABSTRACT Paper AD-87 Unlock SAS Code Automation with the Power of Macros William Gui Zupko II, Federal Law Enforcement Training Centers SAS code, like any computer programming code, seems to
More informationThe Dataset Diet How to transform short and fat into long and thin
Paper TU06 The Dataset Diet How to transform short and fat into long and thin Kathryn Wright, Oxford Pharmaceutical Sciences, UK ABSTRACT What do you do when you are given a dataset with one observation
More informationSo Much Data, So Little Time: Splitting Datasets For More Efficient Run Times and Meeting FDA Submission Guidelines
Paper TT13 So Much Data, So Little Time: Splitting Datasets For More Efficient Run Times and Meeting FDA Submission Guidelines Anthony Harris, PPD, Wilmington, NC Robby Diseker, PPD, Wilmington, NC ABSTRACT
More informationA Mass Symphony: Directing the Program Logs, Lists, and Outputs
PharmaSUG2011 Paper CC24 ABSTRACT A Mass Symphony: Directing the Program Logs, Lists, and Outputs Tom Santopoli, Octagon Research Solutions, Inc., Wayne, PA When executing programs in SAS, it is efficient
More informationCleaning Duplicate Observations on a Chessboard of Missing Values Mayrita Vitvitska, ClinOps, LLC, San Francisco, CA
Cleaning Duplicate Observations on a Chessboard of Missing Values Mayrita Vitvitska, ClinOps, LLC, San Francisco, CA ABSTRACT Removing duplicate observations from a data set is not as easy as it might
More informationA Side of Hash for You To Dig Into
A Side of Hash for You To Dig Into Shan Ali Rasul, Indigo Books & Music Inc, Toronto, Ontario, Canada. ABSTRACT Within the realm of Customer Relationship Management (CRM) there is always a need for segmenting
More informationUsing SAS to Control and Automate a Multi SAS Program Process Patrick Halpin, dunnhumby USA, Cincinnati, OH
Paper T05-2007 Using SAS to Control and Automate a Multi SAS Program Process Patrick Halpin, dunnhumby USA, Cincinnati, OH ABSTRACT Often times a project is comprised of many SAS programs that need to
More informationABSTRACT: INTRODUCTION: WEB CRAWLER OVERVIEW: METHOD 1: WEB CRAWLER IN SAS DATA STEP CODE. Paper CC-17
Paper CC-17 Your Friendly Neighborhood Web Crawler: A Guide to Crawling the Web with SAS Jake Bartlett, Alicia Bieringer, and James Cox PhD, SAS Institute Inc., Cary, NC ABSTRACT: The World Wide Web has
More informationGet into the Groove with %SYSFUNC: Generalizing SAS Macros with Conditionally Executed Code
Get into the Groove with %SYSFUNC: Generalizing SAS Macros with Conditionally Executed Code Kathy Hardis Fraeman, United BioSource Corporation, Bethesda, MD ABSTRACT %SYSFUNC was originally developed in
More informationKEYWORDS Metadata, macro language, CALL EXECUTE, %NRSTR, %TSLIT
MWSUG 2017 - Paper BB15 Building Intelligent Macros: Driving a Variable Parameter System with Metadata Arthur L. Carpenter, California Occidental Consultants, Anchorage, Alaska ABSTRACT When faced with
More informationSummarizing Impossibly Large SAS Data Sets For the Data Warehouse Server Using Horizontal Summarization
Summarizing Impossibly Large SAS Data Sets For the Data Warehouse Server Using Horizontal Summarization Michael A. Raithel, Raithel Consulting Services Abstract Data warehouse applications thrive on pre-summarized
More informationValidation Summary using SYSINFO
Validation Summary using SYSINFO Srinivas Vanam Mahipal Vanam Shravani Vanam Percept Pharma Services, Bridgewater, NJ ABSTRACT This paper presents a macro that produces a Validation Summary using SYSINFO
More informationABSTRACT INTRODUCTION MACRO. Paper RF
Paper RF-08-2014 Burst Reporting With the Help of PROC SQL Dan Sturgeon, Priority Health, Grand Rapids, Michigan Erica Goodrich, Priority Health, Grand Rapids, Michigan ABSTRACT Many SAS programmers need
More informationTired of CALL EXECUTE? Try DOSUBL
ABSTRACT SESUG Paper BB-132-2017 Tired of CALL EXECUTE? Try DOSUBL Jueru Fan, PPD, Morrisville, NC DOSUBL was first introduced as a function in SAS V9.3. It enables the immediate execution of SAS code
More informationODS/RTF Pagination Revisit
PharmaSUG 2018 - Paper QT-01 ODS/RTF Pagination Revisit Ya Huang, Halozyme Therapeutics, Inc. Bryan Callahan, Halozyme Therapeutics, Inc. ABSTRACT ODS/RTF combined with PROC REPORT has been used to generate
More informationSAS PROGRAM EFFICIENCY FOR BEGINNERS. Bruce Gilsen, Federal Reserve Board
SAS PROGRAM EFFICIENCY FOR BEGINNERS Bruce Gilsen, Federal Reserve Board INTRODUCTION This paper presents simple efficiency techniques that can benefit inexperienced SAS software users on all platforms.
More informationSAS PROGRAM EFFICIENCY FOR BEGINNERS. Bruce Gilsen, Federal Reserve Board
SAS PROGRAM EFFICIENCY FOR BEGINNERS Bruce Gilsen, Federal Reserve Board INTRODUCTION This paper presents simple efficiency techniques that can benefit inexperienced SAS software users on all platforms.
More informationBruce Gilsen, Federal Reserve Board
SAS PROGRAM EFFICIENCY FOR BEGINNERS Bruce Gilsen, Federal Reserve Board INTRODUCTION This paper presents simple efficiency techniques that can benefit inexperienced SAS software users on all platforms
More informationThe Power of PROC SQL Techniques and SAS Dictionary Tables in Handling Data
Paper PO31 The Power of PROC SQL Techniques and SAS Dictionary Tables in Handling Data MaryAnne DePesquo Hope, Health Services Advisory Group, Phoenix, Arizona Fen Fen Li, Health Services Advisory Group,
More informationAmie Bissonett, inventiv Health Clinical, Minneapolis, MN
PharmaSUG 2013 - Paper TF12 Let s get SAS sy Amie Bissonett, inventiv Health Clinical, Minneapolis, MN ABSTRACT The SAS language has a plethora of procedures, data step statements, functions, and options
More informationSAS Macro Technique for Embedding and Using Metadata in Web Pages. DataCeutics, Inc., Pottstown, PA
Paper AD11 SAS Macro Technique for Embedding and Using Metadata in Web Pages Paul Gilbert, Troy A. Ruth, Gregory T. Weber DataCeutics, Inc., Pottstown, PA ABSTRACT This paper will present a technique to
More informationEfficient Processing of Long Lists of Variable Names
Efficient Processing of Long Lists of Variable Names Paulette W. Staum, Paul Waldron Consulting, West Nyack, NY ABSTRACT Many programmers use SAS macro language to manipulate lists of variable names. They
More informationMacro to compute best transform variable for the model
Paper 3103-2015 Macro to compute best transform variable for the model Nancy Hu, Discover Financial Service ABSTRACT This study is intended to assist Analysts to generate the best of variables using simple
More informationCombining Contiguous Events and Calculating Duration in Kaplan-Meier Analysis Using a Single Data Step
Combining Contiguous Events and Calculating Duration in Kaplan-Meier Analysis Using a Single Data Step Hui Song, PRA International, Horsham, PA George Laskaris, PRA International, Horsham, PA ABSTRACT
More informationTo conceptualize the process, the table below shows the highly correlated covariates in descending order of their R statistic.
Automating the process of choosing among highly correlated covariates for multivariable logistic regression Michael C. Doherty, i3drugsafety, Waltham, MA ABSTRACT In observational studies, there can be
More informationTales from the Help Desk 5: Yet More Solutions for Common SAS Mistakes Bruce Gilsen, Federal Reserve Board
Tales from the Help Desk 5: Yet More Solutions for Common SAS Mistakes Bruce Gilsen, Federal Reserve Board INTRODUCTION In 25 years as a SAS consultant at the Federal Reserve Board, I have seen SAS users
More informationThe Proc Transpose Cookbook
ABSTRACT PharmaSUG 2017 - Paper TT13 The Proc Transpose Cookbook Douglas Zirbel, Wells Fargo and Co. Proc TRANSPOSE rearranges columns and rows of SAS datasets, but its documentation and behavior can be
More informationIntroduction. Getting Started with the Macro Facility CHAPTER 1
1 CHAPTER 1 Introduction Getting Started with the Macro Facility 1 Replacing Text Strings Using Macro Variables 2 Generating SAS Code Using Macros 3 Inserting Comments in Macros 4 Macro Definition Containing
More informationGet Started Writing SAS Macros Luisa Hartman, Jane Liao, Merck Sharp & Dohme Corp.
Get Started Writing SAS Macros Luisa Hartman, Jane Liao, Merck Sharp & Dohme Corp. ABSTRACT The SAS Macro Facility is a tool which lends flexibility to your SAS code and promotes easier maintenance. It
More informationSTEP 1 - /*******************************/ /* Manipulate the data files */ /*******************************/ <<SAS DATA statements>>
Generalized Report Programming Techniques Using Data-Driven SAS Code Kathy Hardis Fraeman, A.K. Analytic Programming, L.L.C., Olney, MD Karen G. Malley, Malley Research Programming, Inc., Rockville, MD
More informationBreakOnWord: A Macro for Partitioning Long Text Strings at Natural Breaks Richard Addy, Rho, Chapel Hill, NC Charity Quick, Rho, Chapel Hill, NC
PharmaSUG 2014 - Paper CC20 BreakOnWord: A Macro for Partitioning Long Text Strings at Natural Breaks Richard Addy, Rho, Chapel Hill, NC Charity Quick, Rho, Chapel Hill, NC ABSTRACT Breaking long text
More informationA Format to Make the _TYPE_ Field of PROC MEANS Easier to Interpret Matt Pettis, Thomson West, Eagan, MN
Paper 045-29 A Format to Make the _TYPE_ Field of PROC MEANS Easier to Interpret Matt Pettis, Thomson West, Eagan, MN ABSTRACT: PROC MEANS analyzes datasets according to the variables listed in its Class
More informationDocument Downloaded: Thursday December 03, June 2012 C OGR Meeting Thursday Morning MTA Presentation - Finkelstein. Author: Lisa Finkelstein
Document Downloaded: Thursday December 03, 2015 June 2012 C OGR Meeting Thursday Morning MTA Presentation - Finkelstein Author: Lisa Finkelstein Published Date: 06/26/2012 The NIH Transfer Agreement Dashboard
More informationCorrecting for natural time lag bias in non-participants in pre-post intervention evaluation studies
Correcting for natural time lag bias in non-participants in pre-post intervention evaluation studies Gandhi R Bhattarai PhD, OptumInsight, Rocky Hill, CT ABSTRACT Measuring the change in outcomes between
More informationDavid S. Septoff Fidia Pharmaceutical Corporation
UNLIMITING A LIMITED MACRO ENVIRONMENT David S. Septoff Fidia Pharmaceutical Corporation ABSTRACT The full Macro facility provides SAS users with an extremely powerful programming tool. It allows for conditional
More informationCopy That! Using SAS to Create Directories and Duplicate Files
Copy That! Using SAS to Create Directories and Duplicate Files, SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and
More informationHidden in plain sight: my top ten underpublicized enhancements in SAS Versions 9.2 and 9.3
Hidden in plain sight: my top ten underpublicized enhancements in SAS Versions 9.2 and 9.3 Bruce Gilsen, Federal Reserve Board, Washington, DC ABSTRACT SAS Versions 9.2 and 9.3 contain many interesting
More informationApplications Development. Paper 38-28
Paper 38-28 The California Template or How to keep from reinventing the wheel using SAS/IntrNet, JavaScript and process reengineering Blake R. Sanders, U.S. Census Bureau, Washington, DC ABSTRACT Creating
More informationClinical Data Visualization using TIBCO Spotfire and SAS
ABSTRACT SESUG Paper RIV107-2017 Clinical Data Visualization using TIBCO Spotfire and SAS Ajay Gupta, PPD, Morrisville, USA In Pharmaceuticals/CRO industries, you may receive requests from stakeholders
More informationUsing a Control Dataset to Manage Production Compiled Macro Library Curtis E. Reid, Bureau of Labor Statistics, Washington, DC
AP06 Using a Control Dataset to Manage Production Compiled Macro Library Curtis E. Reid, Bureau of Labor Statistics, Washington, DC ABSTRACT By default, SAS compiles and stores all macros into the WORK
More informationA Guided Tour Through the SAS Windowing Environment Casey Cantrell, Clarion Consulting, Los Angeles, CA
A Guided Tour Through the SAS Windowing Environment Casey Cantrell, Clarion Consulting, Los Angeles, CA ABSTRACT The SAS system running in the Microsoft Windows environment contains a multitude of tools
More informationA SAS/AF Application for Linking Demographic & Laboratory Data For Participants in Clinical & Epidemiologic Research Studies
Paper 208 A SAS/AF Application for Linking Demographic & Laboratory Data For Participants in Clinical & Epidemiologic Research Studies Authors: Emily A. Mixon; Karen B. Fowler, University of Alabama at
More informationChapter 6: Modifying and Combining Data Sets
Chapter 6: Modifying and Combining Data Sets The SET statement is a powerful statement in the DATA step. Its main use is to read in a previously created SAS data set which can be modified and saved as
More informationMatt Downs and Heidi Christ-Schmidt Statistics Collaborative, Inc., Washington, D.C.
Paper 82-25 Dynamic data set selection and project management using SAS 6.12 and the Windows NT 4.0 file system Matt Downs and Heidi Christ-Schmidt Statistics Collaborative, Inc., Washington, D.C. ABSTRACT
More informationExporting Access Databases with Indexes and Keys Roger S. Cohen, New York State Dept of Tax and Finance, Albany, New York
Exporting Access Databases with Indexes and Keys Roger S. Cohen, New York State Dept of Tax and Finance, Albany, New York ABSTRACT SAS Access for Microsoft Office Applications allows SAS programs to import
More informationCustomized Flowcharts Using SAS Annotation Abhinav Srivastva, PaxVax Inc., Redwood City, CA
ABSTRACT Customized Flowcharts Using SAS Annotation Abhinav Srivastva, PaxVax Inc., Redwood City, CA Data visualization is becoming a trend in all sectors where critical business decisions or assessments
More informationCreating Macro Calls using Proc Freq
Creating Macro Calls using Proc Freq, Educational Testing Service, Princeton, NJ ABSTRACT Imagine you were asked to get a series of statistics/tables for each country in the world. You have the data, but
More informationPaper CC16. William E Benjamin Jr, Owl Computer Consultancy LLC, Phoenix, AZ
Paper CC16 Smoke and Mirrors!!! Come See How the _INFILE_ Automatic Variable and SHAREBUFFERS Infile Option Can Speed Up Your Flat File Text-Processing Throughput Speed William E Benjamin Jr, Owl Computer
More informationABSTRACT MORE THAN SYNTAX ORGANIZE YOUR WORK THE SAS ENTERPRISE GUIDE PROJECT. Paper 50-30
Paper 50-30 The New World of SAS : Programming with SAS Enterprise Guide Chris Hemedinger, SAS Institute Inc., Cary, NC Stephen McDaniel, SAS Institute Inc., Cary, NC ABSTRACT SAS Enterprise Guide (with
More informationCreate a Format from a SAS Data Set Ruth Marisol Rivera, i3 Statprobe, Mexico City, Mexico
PharmaSUG 2011 - Paper TT02 Create a Format from a SAS Data Set Ruth Marisol Rivera, i3 Statprobe, Mexico City, Mexico ABSTRACT Many times we have to apply formats and it could be hard to create them specially
More informationHash Objects for Everyone
SESUG 2015 Paper BB-83 Hash Objects for Everyone Jack Hall, OptumInsight ABSTRACT The introduction of Hash Objects into the SAS toolbag gives programmers a powerful way to improve performance, especially
More informationThe Demystification of a Great Deal of Files
SESUG 2016 ABSTRACT Paper -AD239 The Demystification of a Great Deal of Files Chao-Ying Hsieh, Southern Company Services, Inc. Atlanta, GA Our input data are sometimes stored in external flat files rather
More informationApplications Development
AD003 User Implementation and Revision of Business Rules Without Hard Coding: Macro-Generated SAS Code By Michael Krumenaker, Sr. Project Manager, Palisades Research, Inc. and Jit Bhattacharya, Manager
More informationYour Own SAS Macros Are as Powerful as You Are Ingenious
Paper CC166 Your Own SAS Macros Are as Powerful as You Are Ingenious Yinghua Shi, Department Of Treasury, Washington, DC ABSTRACT This article proposes, for user-written SAS macros, separate definitions
More informationMacro Quoting: Which Function Should We Use? Pengfei Guo, MSD R&D (China) Co., Ltd., Shanghai, China
PharmaSUG China 2016 - Paper 81 Macro Quoting: Which Function Should We Use? Pengfei Guo, MSD R&D (China) Co., Ltd., Shanghai, China ABSTRACT There are several macro quoting functions in SAS and even some
More informationPharmaSUG Paper TT11
PharmaSUG 2014 - Paper TT11 What is the Definition of Global On-Demand Reporting within the Pharmaceutical Industry? Eric Kammer, Novartis Pharmaceuticals Corporation, East Hanover, NJ ABSTRACT It is not
More informationAutomated Checking Of Multiple Files Kathyayini Tappeta, Percept Pharma Services, Bridgewater, NJ
PharmaSUG 2015 - Paper QT41 Automated Checking Of Multiple Files Kathyayini Tappeta, Percept Pharma Services, Bridgewater, NJ ABSTRACT Most often clinical trial data analysis has tight deadlines with very
More informationA Table Driven ODS Macro Diane E. Brown, exponential Systems, Indianapolis, IN
A Table Driven ODS Macro Diane E. Brown, exponential Systems, Indianapolis, IN ABSTRACT Tired of coding ODS statements and SAS output procedures for every report you write and having redundant or similar
More informationAn Efficient Tool for Clinical Data Check
PharmaSUG 2018 - Paper AD-16 An Efficient Tool for Clinical Data Check Chao Su, Merck & Co., Inc., Rahway, NJ Shunbing Zhao, Merck & Co., Inc., Rahway, NJ Cynthia He, Merck & Co., Inc., Rahway, NJ ABSTRACT
More informationMacros from Beginning to Mend A Simple and Practical Approach to the SAS Macro Facility
Macros from Beginning to Mend A Simple and Practical Approach to the SAS Macro Facility Michael G. Sadof, MGS Associates, Inc., Bethesda, MD. ABSTRACT The macro facility is an important feature of the
More informationT.I.P.S. (Techniques and Information for Programming in SAS )
Paper PO-088 T.I.P.S. (Techniques and Information for Programming in SAS ) Kathy Harkins, Carolyn Maass, Mary Anne Rutkowski Merck Research Laboratories, Upper Gwynedd, PA ABSTRACT: This paper provides
More informationQuality Control of Clinical Data Listings with Proc Compare
ABSTRACT Quality Control of Clinical Data Listings with Proc Compare Robert Bikwemu, Pharmapace, Inc., San Diego, CA Nicole Wallstedt, Pharmapace, Inc., San Diego, CA Checking clinical data listings with
More informationSAS Drug Development Program Portability
PharmaSUG2011 Paper SAS-AD03 SAS Drug Development Program Portability Ben Bocchicchio, SAS Institute, Cary NC, US Nancy Cole, SAS Institute, Cary NC, US ABSTRACT A Roadmap showing how SAS code developed
More informationContents of SAS Programming Techniques
Contents of SAS Programming Techniques Chapter 1 About SAS 1.1 Introduction 1.1.1 SAS modules 1.1.2 SAS module classification 1.1.3 SAS features 1.1.4 Three levels of SAS techniques 1.1.5 Chapter goal
More informationProgram Validation: Logging the Log
Program Validation: Logging the Log Adel Fahmy, Symbiance Inc., Princeton, NJ ABSTRACT Program Validation includes checking both program Log and Logic. The program Log should be clear of any system Error/Warning
More informationKnow What You Are Missing: How to Catalogue and Manage Missing Pieces of Historical Data
Know What You Are Missing: How to Catalogue and Manage Missing Pieces of Historical Data Shankar Yaddanapudi, SAS Consultant, Washington DC ABSTRACT In certain applications it is necessary to maintain
More informationAcknowledgments xi Preface xiii About the Author xv About This Book xvii New in the Macro Language xxi
Contents Part 1 Acknowledgments xi Preface xiii About the Author xv About This Book xvii New in the Macro Language xxi Macro Basics Chapter 1 Introduction 3 1.1 Macro Facility Overview 3 1.2 Terminology
More informationThe Ugliest Data I ve Ever Met
The Ugliest Data I ve Ever Met Derek Morgan, Washington University Medical School, St. Louis, MO Abstract Data management frequently involves interesting ways of doing things with the SAS System. Sometimes,
More informationPharmaSUG China. Systematically Reordering Axis Major Tick Values in SAS Graph Brian Shen, PPDI, ShangHai
PharmaSUG China Systematically Reordering Axis Major Tick Values in SAS Graph Brian Shen, PPDI, ShangHai ABSTRACT Once generating SAS graphs, it is a headache to programmers to reorder the axis tick values
More informationCC13 An Automatic Process to Compare Files. Simon Lin, Merck & Co., Inc., Rahway, NJ Huei-Ling Chen, Merck & Co., Inc., Rahway, NJ
CC13 An Automatic Process to Compare Files Simon Lin, Merck & Co., Inc., Rahway, NJ Huei-Ling Chen, Merck & Co., Inc., Rahway, NJ ABSTRACT Comparing different versions of output files is often performed
More informationWhat to Expect When You Need to Make a Data Delivery... Helpful Tips and Techniques
What to Expect When You Need to Make a Data Delivery... Helpful Tips and Techniques Louise Hadden, Abt Associates Inc. QUESTIONS YOU SHOULD ASK REGARDING THE PROJECT Is there any information regarding
More informationWhat's the Difference? Using the PROC COMPARE to find out.
MWSUG 2018 - Paper SP-069 What's the Difference? Using the PROC COMPARE to find out. Larry Riggen, Indiana University, Indianapolis, IN ABSTRACT We are often asked to determine what has changed in a database.
More informationMacros to Report Missing Data: An HTML Data Collection Guide Patrick Thornton, University of California San Francisco, SF, California
Macros to Report Missing Data: An HTML Data Collection Guide Patrick Thornton, University of California San Francisco, SF, California ABSTRACT This paper presents SAS macro programs that calculate missing
More informationWhile You Were Sleeping, SAS Was Hard At Work Andrea Wainwright-Zimmerman, Capital One Financial, Inc., Richmond, VA
Paper BB-02 While You Were Sleeping, SAS Was Hard At Work Andrea Wainwright-Zimmerman, Capital One Financial, Inc., Richmond, VA ABSTRACT Automating and scheduling SAS code to run over night has many advantages,
More informationSAS CURRICULUM. BASE SAS Introduction
SAS CURRICULUM BASE SAS Introduction Data Warehousing Concepts What is a Data Warehouse? What is a Data Mart? What is the difference between Relational Databases and the Data in Data Warehouse (OLTP versus
More informationBetter Metadata Through SAS II: %SYSFUNC, PROC DATASETS, and Dictionary Tables
Paper 3458-2015 Better Metadata Through SAS II: %SYSFUNC, PROC DATASETS, and Dictionary Tables ABSTRACT Louise Hadden, Abt Associates Inc., Cambridge, MA SAS provides a wealth of resources for users to
More informationUsing an Array as an If-Switch Nazik Elgaddal and Ed Heaton, Westat, Rockville, MD
Using an Array as an If-Switch Nazik Elgaddal and Ed Heaton, Westat, Rockville, MD Abstract Do you sometimes find yourself using nested IF statements or nested SELECT blocks? Does the code become more
More informationFoundations and Fundamentals. SAS System Options: The True Heroes of Macro Debugging Kevin Russell and Russ Tyndall, SAS Institute Inc.
SAS System Options: The True Heroes of Macro Debugging Kevin Russell and Russ Tyndall, SAS Institute Inc., Cary, NC ABSTRACT It is not uncommon for the first draft of any macro application to contain errors.
More informationEdit the Editor: Creating Keyboard Macros in SAS Enterprise Guide
Paper 3502-2015 Edit the Editor: Creating Keyboard Macros in SAS Enterprise Guide Christopher J. Bost, MDRC, New York, NY ABSTRACT Programmers can create keyboard macros to perform common editing tasks
More informationOut of Control! A SAS Macro to Recalculate QC Statistics
Paper 3296-2015 Out of Control! A SAS Macro to Recalculate QC Statistics Jesse Pratt, Colleen Mangeot, Kelly Olano, Cincinnati Children s Hospital Medical Center, Cincinnati, OH, USA ABSTRACT SAS/QC provides
More informationDATA Step Debugger APPENDIX 3
1193 APPENDIX 3 DATA Step Debugger Introduction 1194 Definition: What is Debugging? 1194 Definition: The DATA Step Debugger 1194 Basic Usage 1195 How a Debugger Session Works 1195 Using the Windows 1195
More informationAn Introduction to SAS Macros
An Introduction to SAS Macros Expanded token SAS Program (Input Stack) SAS Wordscanner (Tokenization) Non-Macro (Tokens) SAS Compiler % and & Triggers Macro Facility Steven First, President 2997 Yarmouth
More informationHow a Code-Checking Algorithm Can Prevent Errors
How a Code-Checking Algorithm Can Prevent Errors 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.
More informationEssentials of PDV: Directing the Aim to Understanding the DATA Step! Arthur Xuejun Li, City of Hope National Medical Center, Duarte, CA
PharmaSUG 2013 - Paper TF17 Essentials of PDV: Directing the Aim to Understanding the DATA Step! Arthur Xuejun Li, City of Hope National Medical Center, Duarte, CA ABSTRACT Beginning programmers often
More informationSQL-Server. Insert query in SQL Server. In SQL Server (Transact-SQL), the INSERT statement is used to
Insert query in SQL Server In SQL Server (Transact-SQL), the INSERT statement is used to insert a data into the table. It can be a single record or multiple records into a table in SQL Server. The INSERT
More information