Coders Corner

 

 

Section Chairs:

Ian Whitlock

Westat, Inc.

Rockville, MD

Susan Kenny

Quintiles, Inc.

Research Triangle Park, NC

 

 

   
   

Stratified Weighting of Sample Data for Descriptive Purposes

   

David L. Alderton, Ph.D., Centers for Disease Control and Prevention, Atlanta, GA

   

The effect of stratifying a sample is that the marginal distribution of the strata (e.g., sex, race/ethnicity, and age) will be the same in the sample as in a source population or another sample. The logic for weighting a sample is similar to that for selecting a stratified sample. Weights can be calculated to sum to the sample size or population size as seems fit. The weighting procedure is straightforward and the technique can be used to descriptively compare groups on outcome measures without resorting to methods of statistical control such as partial correlations in regression models. An advantage of sample weighting is that many outcome variables can be descriptively viewed, whereas, if strata differences were statistically controlled, a new regression (or other) model would have to be calculated for each outcome measure. To exemplify this technique, the 38,701 cases from the Adult and Adolescent Spectrum of Disease (ASD) Project were weighted to match the 591,302 cases in the National HIV/AIDS Reporting System population for sex, race/ethnicity, age group, and mode of HIV infection. After weighting the ASD data it was possible to estimate the relative occurrence of 26 opportunistic infections as they would have occurred in the national population.

   

David L. Alderton received his Ph.D. in psychology in 1986. He did psychometric research on intelligence and problem solving with the US Navy. In 1993 he began working at the Centers for Disease Control and Prevention and currently does epidemiological and survey sampling research on behaviors leading to HIV infection and AIDS with the HIV/AIDS Surveillance Branch where the national data on HIV infection is maintained. He has been a SAS user since 1982.

   

New Data Step Functions in SAS 6.12 - Part I Data Set Functions

   

Caroline Bahler, Independent Consultant, Radford, VA

   

The Data Step in SAS 6.12 is the recipient of 50+ new functions. These new functions are broken into the following groupings data set functions, external file functions, library and catalog functions, special functions, variable functions, and statistica l functions. The objective of this paper is to discuss the data set functions and their potential uses.

   

Caroline Bahler has been using SAS for the last 18 years. She started using SAS in the good old days of punch cards and documentation consisted of only 2 books and she has continued to use SAS through all of the succeeding versions. Presently, her SAS repetory includes AF, BASE, GRAPH, CONNECT, ACCESS for dB2, Oracle, AS/400 and Excel/Dbase, and STAT. Caroline Bahler has a Ph.D. in Agronomy and has refined her SAS skills in both the research and business environments.

   

New Data Step Functions in SAS 6.12 - Part II External File Functions

   

Caroline Bahler, Independent Consultant, Radford, VA

   

The Data Step in SAS 6.12 is the recipient of 50+ new functions. These new functions are broken into the following groupings data set functions, external file functions, library and catalog functions, special functions, variable functions, and statistical functions. The objective of this paper is to discuss the external file functions and their potential uses.

   

Caroline Bahler has been using SAS for the last 18 years. She started using SAS in the good old days of punch cards and documentation consisted of only 2 books and she has continued to use SAS through all of the succeeding versions. Presently, her SAS repetory includes AF, BASE, GRAPH, CONNECT, ACCESS for dB2, Oracle, AS/400 and Excel/Dbase, and STAT. Caroline Bahler has a Ph.D. in Agronomy and has refined her SAS skills in both the research and business environments.

   

New Data Step Functions in SAS 6.12 - Part III Special Functions

   

Caroline Bahler, Independent Consultant, Radford, VA

   

The Data Step in SAS 6.12 is the recipient of 50+ new functions. These new functions are broken into the following groupings data set functions, external file functions, library and catalog functions, special functions, variable functions, and statistical functions. The objective of this paper is to discuss the special functions and their potential uses.

   

Caroline Bahler has been using SAS for the last 18 years. She started using SAS in the good old days of punch cards and documentation consisted of only 2 books and she has continued to use SAS through all of the succeeding versions. Presently, her SAS repetory includes AF, BASE, GRAPH, CONNECT, ACCESS for dB2, Oracle, AS/400 and Excel/Dbase, and STAT. Caroline Bahler has a Ph.D. in Agronomy and has refined her SAS skills in both the research and business environments.

   

SAS Changes and Enhancements for Version 6.11 and Version 6.12

   

Arturo Barrios, University of North Carolina, Chapel Hill, NC

   

Release 6.11 and 6.12 of the SAS System introduced a number of new features, some of which the author gives rave reviews and some of which she is less enthusiastic about. Some of the new features that will be discussed:

  • Reading and Writing External and SAS files between hosts
  • Using the Online HELP
  • Converting SAS catalogs, including Format Libraries
  • Changing colors in windows
  • Using Data Manager statements
  • Using Print Manager
  • Temporary Datasets
  • Changing the Default Working Directory
  • Memory
   

Arturo Barrios is a Computer Consultant for the Customer Services Division of Academic Technology and Networks (ATN) at the University of North Carolina. Arturo began using SAS as a graduate student in the Dept. of City and Regional Planning, in 1991. He progressed to supporting SAS as a Computer Consultant and teaching SAS Short Courses, including SAS/ASSIST, SAS/CONNECT, and soon "Putting a SAS Application on the Web".

   

Cautionary Tales for SAS Programmers (or, Coding Pitfalls for the Unwary)

   

Jerry Le Breton, Independent SAS Consultant, Rationale Pty Ltd, Canberra, Australia

(Paper presented by Ian Whitlock, Westat Inc., Rockville, MD)

   

This paper will help both experienced SAS users and beginners to avoid common, coding traps when using Base SAS; traps that stem from some less-than-obvious features of the SAS System, and wide-spread misconceptions of its default behavior.

The ease of getting started with Base SAS programming belies the breadth and depth of the SAS language. It can also lead users into trouble. Since users can generate results by writing just a minimal amount of code, and leaving the SAS System to 'fill in the blanks', they often don't realize or understand what SAS is doing for them behind the scenes. Its often not what they expect. And many experienced users are just as likely to be surprised as beginners. Indeed, the experienced users often create more serious errors because of their greater, and sometimes misplaced, confidence.

Being aware of the most dangerous features will, of course, avoid potential problems, but so too will good programming practice - long before all the manuals have been consigned to memory.

This paper highlights a few classic traps, and how to avoid them. It will also demonstrate that the know-alls, don't!

   

Jerry is an Independent SAS Consultant, based in Canberra, Australia. He have a BS degree in computing from Loughborough University, UK. He now specializes in SAS/AF, FRAMEs, and Base SAS software, and have been a SAS user for 8 years.

Ian Whitlock is a senior systems analyst at Westat working on survey research problems. He has been programming largely in SAS since 1981 using an interactive environment to develop programs for execution in a batch environment. He is active on SAS-L, and has presented many different papers at national, regional, and local SAS User Group meetings.

   

Using Indexes for Direct Access to SAS Datasets

   

Judy Loren, Independent Consultant

   

Indexing SAS datasets was introduced in Version 6 of SAS. The ability to use indexes for direct access to SAS datasets via the KEY= option allows one to solve simply problems that before indexing were either long and tedious to code or executed "forever". This paper contains specific programming suggestions to make SET with KEY= work the way you want (and only the way your want). In short, it goes beyond the documentation given in Technical Report P-222, Changes and Enhancements to Base SAS Software, Release 6.07.

   

Judy Loren has been using batch SAS under MVS since 1978. She was introduced to computers by her grandmother, who started programming back when software meant wiring the hardware. She let Judy punch a card in 1967, and Judy never looked back.

   

Standardizing Output: PROC TRANSPOSE to the Rescue

   

Judy Loren, Independent Consultant

   

Let's suppose you have to write some code that will produce a particular summary report on a regular basis. Let's further suppose that one of your class variables may not be fully represented, that is, the data may be sparse. If you simply use PROC SUMMARY to produce the report, the combination of values that isn't represented in the data source just doesn't appear in the final report. If your user wants the same format every time, what do you do? Use PROC TRANSPOSE twice!

   

Judy Loren has been using batch SAS under MVS since 1978. She was introduced to computers by her grandmother, who started programming back when software meant wiring the hardware. She let Judy punch a card in 1967, and Judy never looked back.

   

Creating A Private Menu to Customize Your SAS Interface

   

Sally Muller, University of North Carolina, Chapel Hill, NC

   

By default when you invoke SAS/ASSIST, you get a particular interface. You can change this interface completely or simply modify it. By using the "private menu" provided by the SAS/ASSIST software, this operation is unimaginably easy. This paper presents the procedure for creating your own SAS/ASSIST application. After creating such an application when you invoke SAS/ASSIST, your own private menu will appear instead of the SAS/ASSIST Primary Menu. Your private menu enables you to access frequently performed tasks immediately. The ease with which this can be accomplished makes it ideal for creating private menus for sites where a group of people are working on similar tasks.

   

Sally Muller is the Manager of the Research Support Group in the Customer Services Division of Academic Technology and Networks (ATN) at the University of North Carolina. Sally began using SAS software as a programmer in 1978 and became a site representative in 1987. Since then she believes she has answered over 10 million of SAS user questions and taught several thousand introductory SAS classes, but admits that these numbers may be **slightly** inflated. Sally found that in teaching these students, who were often completely new to the computer, that SAS/ASSIST could provide a simple, nonthreatening, and yet very capable, tool for using the SAS System. A desire to share this revelation with other teachers of novice SAS users, was the inspiration of this paper.

   

Your Friend the Colon: Some Efficiency Techniques for Comparing or Selecting Character Data

   

S. David Riba, JADE Tech, Inc., Clearwater, FL

   

There are many techniques that can be used when comparing or selecting character data. One of the most useful is also probably one of the least known. When used to modify comparison operators, the colon ( : ) can greatly improve the flexibility of the comparison operator while considerably simplifying the resulting SAS program code. This modifier has been part of Base SAS since the days of Version 5 or earlier. This presentation will review some typical uses where the colon modifier can improve on typical programming methods when comparing or selecting character data.

   

S. David Riba is CEO of JADE Tech, Inc., a SAS Institute Quality Partner who specializes entirely in applications development, consulting, and training in the SAS System. He is the founder and President of the Florida Gulf Coast SAS Users Group. He chartered and served as Co-Chair of the first SouthEast SAS Users Group conference, SESUG '93, and serves as President of the Executive Council of the SouthEast SAS Users Group. His first SUGI was in 1983, and he has been actively involved in both SUGI and the Regional SAS Users Group community since then. He has presented papers and assisted in various capacities at SUGI, SESUG, NESUG, MWSUG, SCSUG, and PharmaSUG. Dave is an unrepentant SAS bigot. His major areas of interest are efficient programming techniques and applications development using the SAS System, particularly using Screen Control Language with SAS/AF and FRAME technology.

   

Word-Wrapping Text Output in SAS Reports

   

S. David Riba, JADE Tech, Inc., Clearwater, FL

   

How do you get your SAS output that normally prints text values in a very long line

to wrap in smaller lines at word breaks

just like a word processor

typically does?

The problem with printing long text values in SAS is that either a) your output gets truncated when the next field writes over it or b) you can split the values at a certain line length which may, or may not, be at a break between words. This datastep routine parses long text values into smaller output lines based on the output line length that has been defined. Instead of merely splitting the line, it defines the closest gap between words and breaks at that point.

   

S. David Riba is CEO of JADE Tech, Inc., a SAS Institute Quality Partner who specializes entirely in applications development, consulting, and training in the SAS System. He is the founder and President of the Florida Gulf Coast SAS Users Group. He chartered and served as Co-Chair of the first SouthEast SAS Users Group conference, SESUG '93, and serves as President of the Executive Council of the SouthEast SAS Users Group. His first SUGI was in 1983, and he has been actively involved in both SUGI and the Regional SAS Users Group community since then. He has presented papers and assisted in various capacities at SUGI, SESUG, NESUG, MWSUG, SCSUG, and PharmaSUG. Dave is an unrepentant SAS bigot. His major areas of interest are efficient programming techniques and applications development using the SAS System, particularly using Screen Control Language with SAS/AF and FRAME technology.

   

Finding and Using Unusual Characters

   

Bob Virgile, Robert Virgile Associates, Inc., Woburn, MA

   

From time to time, the keyboard does not provide you with all the characters you might like to use. For example, if you are editing your SAS output in the program editor, you might want to insert a page break character. Or if you are using a PC to emulate a mainframe terminal, you might want a solid vertical bar to concatenate character strings. How can you find out what characters are available in your environment, and how they will be displayed if sent to the printer? Come to coder's corner and find out!

   

Bob Virgile is an independent SAS consultant. He has written numerous papers, books, and problem solving contests. He also develops and teaches an exceptional series of SAS classes

   

An Iterative Loop of SQL Code

   

Ian Whitlock, Westat, Inc., Rockville, MD

   

Some problems with good PROC SQL solutions require an iterative step. A good intuitively simple illustrative example was presented as a question in the first quarter of 1997 on SAS-L. This paper restates the problem and gives a simple SQL solution using very simple macro code for the iterative loop

   

Ian Whitlock is a senior systems analyst at Westat working on survey research problems. He has been programming largely in SAS since 1981 using an interactive environment to develop programs for execution in a batch environment. He is active on SAS-L, and has presented many different papers at national, regional, and local SAS User Group meetings.