Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Oracle Database wikipedia , lookup
Open Database Connectivity wikipedia , lookup
Entity–attribute–value model wikipedia , lookup
Extensible Storage Engine wikipedia , lookup
Microsoft Jet Database Engine wikipedia , lookup
Concurrency control wikipedia , lookup
Relational model wikipedia , lookup
Clusterpoint wikipedia , lookup
Standards and Macros: The Keystroke-Bustersl Judy A.D. Alicante, Pacific Gas and Electric Company I. SAS Data Base Naming Conventions: ABSTRACT As SAS® programmers, how many times do you have to key Our group's SAS database naming convention is as follows: in: PROC CONTENTS DATA=DDNAMEo_ALL_ NODS; RUN; How about: T50 ALLOC F(DDNAME) DA('MYID.MYFILE.DATA'); Has keying in the same code over and over again in one interactive session ever irr~ated you? Well, you are not alone. RATE76.SAS.qqqqqqqq.tttttt where RATE 76 SAS qqqqqqqq tttttt =====> Rates Department file s====> output bin number ==:~=> identifies it as a SAS database =====> database qualifier =_s:=> database type (1) for personal databases: RATE76.SAS.AA16.DATA At one point or another, all programmers are irritated by such repit~ion. These Irustrations often happen during interactive sessions when the programmer is debugging his code or when he is doing some analysis on existing data. Many 01 theselrustrations can be eliminated by minimal planning and coding. where DATA ======> database type AA76 ======> database ~lifier (2) for system databases: By establishing standards and naming conventions-and adhering to thelll-i>rogrammers can develop generic macros that minimize the amount 01 typing. These macros can be shared by all programmers in a group that lollows the same standards and conventions. RATE76.SAS.GASBILL.LIBREF where LIBREF GASBILL This paper shows how standards, conventions, and macros can save keystrokes. ======> ======> database type database qualifier (3) for project or data request data bases: RATE76.SAS.ACAP.DATA =3> project database RATE76.SAS.DR246.DATA ==> data request database INTRODUCTION The personal database is the database we use to store datasets that we need only for a short period of time-from two days to a week or even a month. Usually, other programmers are not interested in the datasets that we keep in our personal database. I think all 01 us would agree that standards are helplul. For example, most 01 the appliances we use every day conform to certain standards of salety and convenience. Think 01 the many appliances We use at home. ff each appliance had a dillerent size and shape 01 plug, you would have to install many kinds of electrical outlets in your hom&-<lne lor each appliance. For personal databases, our TSO USERID is our database In this case, the owner of this database's USERID is AA76. The last node 01 the personal database name is DATA, which is what we call the database type. qual~ier. Now, here's an example that is close and dear to my heartthe VCR revolution. Right now we have three VCR lormats: Beta, VHS, and 8-mm. My sister has a Beta recorder, my brother has a VHS, and I have an 8-mm. My husband and I bought an 8-mm deck because the rumor is that "8-mm is the video lormat of the future.· I hope ~ is because I'd like to exchange video tapes with my lamily. System databases hold our main data files. The database qual~ier tells us what type 01 data the database holds. The last node in the database name is LlBREF, which tells us that this is a system database. In the example above, the database qual~ier GASBILL tells us that the database holds gas billing data. These two examples should convince you that standards are important. Having standards makes I~e a little easier. And that is also true in the data processing world. The project or data request database holds the datasets that are used to answer spec~ic data requests. In the example above, the database was used or is being used to answer data request number 246. UsuaUy the files stored here were extracted Irom system !nes like GASBILl, and then manipulated to answer the specific request. Sometimes, instead of a data request number, the name olthe actual project or filing is used as the database qual~ier (ACAP in the example above). Right now, I want to talk about the standards that you and I can implement ourselves-<mes that we can control directly. I am talking about the standards and conventions that you and your colleagues at work can develop and adhere to. These are standards that can save you a lot of keystrokes. NAMING CONVENTIONS & GENERIC MACROS In the department where I wor1<, the programmers in our group have developed standards and naming conventions on a number 01 things. I'll show you some 01 those standards and how they are helping us. It Ddname or Filename Naming Conventions: We also have a filename convention. This convention is simple, but a very powerful keystroke-buster. 1535 When we allocate a database, we almost always use DBN as the filename or ddname. When we have to allocate more than one database, then we are free to choose any name we want. 'let l='quote(alloc da'("RATE76.SAS.&q; 'let l~'l •• DATA"') SHR REUSE F'(&d'»; \tso '1; 'mend SHARE; See how the ddname delauns to DBN when only one parameter is used with this macro. When two parameters are supplied, the macro reeds the lirst parameter as the ddname and the second parameter as the database qualifiar. With these simple naming conventions, programmers in our group developed generic macros that minimize the amount of typing we do. Macros can be used by all programmers in a group following the same standards and conventions. Remember, the key is that everyone has to follow the same standards and conventions. Ahhough this presentation is not about documentation, I want to mention what our group calls the owner b1ock-that comment box just before the actual macro SHARE definition. All codes in our group must have an owner block or else the writer will be tortured beyond his or her wildest dreams. Because 01 that threat, it is now a habit by all programers in our group to have an owner block. THE KEYSTROKE-BUSTERS IN ACTION Here is a specKic example of how the keystroke-busters work. Assuming you are doing some interactive work in SAS using the mainframe MVSfTSO system. LONG WAY: Let's take note of the macro name SHARE. See how a good descriptive macro name was used for allocating a shared database (i.e., you are letting other people share the database with you). With that, you might have guessed that we have a macro that allows us to allocate databases exclusively. And, of course, we named the macro appropriately. TSO ALLoe F(DBN) DA('RATE76.SAS.AA16.0ATA") SHR: ==> 48 keystrokes Now, using a macro that our group developed utilizing the naming convention that we have: SHORT WAY: SHARE AA76; ==> HOG MYFILE; 11 keystrokes In our environment, these two commands are identical. They both allocate shared the same database using the same filename. So, which one would you rather use -the one that will take you 48 keystrokes or the one with only 11 keystrokes? Here's a few more macros that we often use: 1. To list all the data sets in a data base: LONG WAY: PRoe CONTENTS DATA '" '" '" '" * '" '" '" * * '" '" '" * '" '" * '" '" '" '" * *: * Macro name: SHARE *; *; * *; '" Description: * If only one argument is '" ,., ,., '" *; this macro attaches the ddname of dbn shared (or read only) to the standard RATE76 data base specified as the first and only argument. 'CAT; *; *; *; *; *; '" specified as the second argument with * the ddname specified as the first * argument. *: NODS; RUN: ~""> - 44 keystrokes *; MACRO WAY: *: 'CAT(DB=DTFILE); *; * * * * * * * * * TSO SPF 2; 1< * • * • * * * * • * • 10 keystrokes MACRO WAY: *: *; * Date: Revised by: * Revision Description: 16 keystrokes LONG WAY: '*; '* Revision: * -==> 3. For lazy people (like me) who go back and forth between SASand SPF: Example: *; * share dbnl enduse: *: * This example attaches the ENDUSE data base*; * with read-only status using dbnl as *; * filename. '*: * 5 keystrokes LONG WAY: PRoe CONTENTS DATA = DTFILE. ALL *; * '* ==> 2. To list all the data sets in a data base when DBN is not the filename: *; If two arguments are supplied, the macro '" attaches thestandard RATE76 data base NODS; RUN; ~=> 38 keystrokes MACRO WAY: *; * * ALL = DBN. - *: supplied~ 11 keystrokes The word HOG reminds you that you are hogging the database and that no one else but you can use it. This statement style SHARE macro looks like this: '" Location: RATE76.AUTOMACS(SHARE) * Author: PETER KRETZMAN Date: 9/19/85 ==> SPF 2; *, *; ==> 6 keystrokes *; 4. To route procedure output to a local printer: *; LONG WAY: * * '* *: TSO FREE F(FT18F001); TSO ALLOC F(FT18F001) SYSOUT(B) DEST(GPU02); 'macro SHARE(d1q)/stmt; 'if &q= 'then 'do; 'let q=&d; 'let d:DSN; 'end; OPTIONS PAGESIZE=6Q LINESIZE=132; PRoe PRINTTO UNIT=18; RUN; MACRO WAY: OUTS; 1536 5. To direclthe procedure output back to the terminal: LONG WAY: OPTIONS PAGESIZE=23 LINESIZE=72; PROC PRINTTO; RUN; MACRO WAY: OUTTERM; Standards and conventions save more than keystrokes: they also save spoken words and improve communications among data processing people. When we are talking about databases in our group, we never talk about RATE76.SAS.GASBILl.LlBREF. Wesimplysay"GASBILL" and everyone knows exactly what we are talking about. We no longer need to spell out the name of the file. CONCLUSION Our group has many macros that we use all the time, too numerous to present in one paper. I have shown you the ones that are very common and straightforward. Hopefully, I have convinced you that by establishing standards and naming conventions-and adheringtothem-prograrnmers can develop generic macros that minimize the amount of typing. These macros can be shared by all programmers in a group following the same standards and conventions. W~h standards in place, your group can develop Mown keystroke-buster macros. ACKNOWLEDGEMENTS Thanks to Gloria Re~erman, Louise Weiler, Mary Austin, Peter Kretzman and Danine Cozzens for their invaluable contributions. Special thanks also to all Rates DepartmentRate Data Services personnel for their help and cooperation in developing this presentation. Note: SAS® is a registered trademark of SAS Institute Inc., Cary, NC, USA. 1537