Call Execute For Everyone

1,292 views

Published on

An example of using SAS CALL EXECUTE for a data manager, a programmer and a statistician.

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,292
On SlideShare
0
From Embeds
0
Number of Embeds
21
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Call Execute For Everyone

  1. 1. CALL EXECUTE for everyone! Examples for programmer, statistician, and data manager
  2. 2. Overview <ul><li>Short introduction CALL EXECUTE </li></ul><ul><li>Examples: </li></ul><ul><li>Programmer </li></ul><ul><li>Statistician </li></ul><ul><li>Data Manager </li></ul>
  3. 3. Remember <ul><li>The DATA step operates as a loop </li></ul><ul><li>CALL EXECUTE writes the code as the DATA step is processed </li></ul><ul><li>The generated code can use values from SAS data set variables </li></ul><ul><li>This code is executed after the DATA step </li></ul><ul><li>Keep it simple </li></ul>
  4. 4. Where do I start? <ul><li>Work Backwards </li></ul><ul><li>Write the basic statement in open code </li></ul><ul><li>Pick out the pieces of code to be replaced by data set variables </li></ul><ul><li>Create a data set containing the values needed for your basic statement </li></ul><ul><li>Write a DATA step with CALL EXECUTE </li></ul>
  5. 5. 1. Programmer
  6. 6. The Problem <ul><li>Run all programs in a directory or in many directories. </li></ul><ul><li>One program with %INCLUDE statements. </li></ul><ul><li>Misspellings , new programs </li></ul>
  7. 7. Work Backwards <ul><li>Basic code: </li></ul><ul><li>%INCLUDE &quot; Z:XXXprogname.sas &quot; ; </li></ul><ul><li>Will Translate into: </li></ul><ul><li>CALL EXECUTE( '%INCLUDE &quot;Z:XXX' ||pgmname|| '&quot;;' ); </li></ul>Data set variable Piece to replace
  8. 8. Create the Data set <ul><li>FILENAME file1 PIPE 'dir Z:XXXPrograms' ; </li></ul><ul><li>DATA sasfiles; </li></ul><ul><li>LENGTH pgmname $ 200 ; </li></ul><ul><li>INFILE file1 TRUNCOVER ; </li></ul><ul><li>INPUT sasfile $ 1 - 200 ; </li></ul><ul><li>pgmname=SCAN(sasfile,- 1 , ' ' ); </li></ul><ul><li>IF SCAN(sasfile,- 1 , '.' )= 'sas' ; </li></ul><ul><li>RUN ; </li></ul>
  9. 9. Resulting in:
  10. 10. Final Code <ul><li>DATA _NULL_ ; </li></ul><ul><li>SET sasfiles; </li></ul><ul><li>CALL EXECUTE( '%INCLUDE &quot;Z:XXX' ||pgmname|| '&quot;;' ); </li></ul><ul><li>RUN ; </li></ul>
  11. 11. What happens?? <ul><li>NOTE: CALL EXECUTE generated line. </li></ul><ul><li>1 + %INCLUDE Z:XXXProgram1.sas </li></ul><ul><li>... </li></ul><ul><li>NOTE: CALL EXECUTE generated line. </li></ul><ul><li>2 + %INCLUDE Z:XXXProgram2.sas </li></ul><ul><li>... </li></ul><ul><li>NOTE: CALL EXECUTE generated line. </li></ul><ul><li>3 + %INCLUDE Z:XXXProgram3.sas </li></ul><ul><li>... </li></ul><ul><li>NOTE: CALL EXECUTE generated line. </li></ul><ul><li>4 + %INCLUDE Z:XXXProgram4.sas </li></ul>
  12. 12. 2. Statisticians
  13. 13. The Problem <ul><li>Create consistent symbols for Graphs </li></ul><ul><li>Lab graphs with subpopulations </li></ul>
  14. 14. Simple Graph
  15. 15. Simple Graph
  16. 16. Subpopulation
  17. 17. Solution? <ul><li>Write the SYMBOL statements based on the values of treatment (TPATT) </li></ul>
  18. 18. Create macro variables containing SYMBOL definition. Common Prefix Value of Treatment SYMBOL Definition
  19. 19. Data Set with Treatments to be Used in Graph
  20. 20. Create our a little more complex CALL EXECUTE <ul><li>DATA _NULL_ ; </li></ul><ul><li>SET _trts; </li></ul><ul><li>CALL EXECUTE ( 'SYMBOL' ||PUT(_N_, 8. -L)|| ' &trt' ||LEFT(tpatt)|| ';' ); </li></ul><ul><li>RUN ; </li></ul>Incremental Number Common Prefix Value of Treatment
  21. 21. What happens?? <ul><li>NOTE: CALL EXECUTE generated line. </li></ul><ul><li>1 + SYMBOL1 I=J V=CIRCLE L=7 C=BLACK; </li></ul><ul><li>2 + SYMBOL2 I=J V=STAR L=3 C=BLACK; </li></ul><ul><li>3 + SYMBOL3 I=J V=DIAMOND L=5 C=BLACK; </li></ul><ul><li>4 + SYMBOL4 I=J V=DOT L=1 C=BLACK; </li></ul>
  22. 22. With 3 groups <ul><li>NOTE: CALL EXECUTE generated line. </li></ul><ul><li>1 + SYMBOL1 I=J V=CIRCLE L=7 C=BLACK; </li></ul><ul><li>2 + SYMBOL2 I=J V=STAR L=3 C=BLACK; </li></ul><ul><li>3 + SYMBOL3 I=J V=DOT L=1 C=BLACK; </li></ul>
  23. 23. Statisticians are happy now!
  24. 24. 3. Data Managers
  25. 25. The Problem <ul><li>Search through LIBNAMEs for incorrect data points (Dates, negative values etc.) </li></ul><ul><li>Time consuming! </li></ul>
  26. 26. Basic Code %LET lib=PHARMA; %LET lockdt='23SEP2005'D;
  27. 27. Find all date variables in &lib.
  28. 28. Multiple Records per LIBDOTMEM
  29. 29. Compress Data into One Record per LIBDOTMEM
  30. 30. Final Data Set!
  31. 31. Easy CALL EXECUTE Statement
  32. 33. Contact info: Daniel Boisvert Genzyme Corporation [email_address] Shafi Chowdhury [email_address] www.shaficonsulatancy.com
  33. 34. Questions, comments or complaints?

×