5
Searching a catalog for text Such a tool does not directly exist, but there is a way Using PROC BUILD you can write all the source text from catalog entries to an external file Then use FSLIST to view the file, or notepad, MS Word, to search it, e.g.e.g. %macro catscan(cat,file) ; proc build catalog=&cat batch ; print source prtfile="&file" ; run ; dm 'fslist "&file"' fslist ; %mend catscan ;

7
Using Progress Bars in Base SAS (1 of 2) You can produce progress bars for use in Data Steps or Macros. –Useful to let users know how a long macro is progressing This example shows how to do so for a data stepexample –A similar technique can be used from macro language using the %WINDOW and %DISPLAY statements. Key points –Define a window shaped like a bar –Redisplay it each time we have some progress –Just change value and link to routine to update bar

11
Mixing data step & SQL code You can have data step code in an SQL statement, e.g. e.g. data out / view=out ; set sasuser.houses ; if style='CONDO' then put 'obs=' _n_ price= ; run ; proc sql ; create table more as select * from out where price > ; ;quit;run; –This creates a dataset and writes some variable information to the log Can similarly have SQL code within a data step, by using views

12
Sort Techniques based on my investigations 3x data size for sort space (rule-of-thumb) Compress=yes & sort can save time (-8%) Tagsort, good on large datasets where key is small (e.g. -49%) Almost always use Noequals (e.g. 5%) Combine datastep code with sort using VIEW (e.g. -27%)e.g. –More on next slide …

15
Making log available during non- interactive SAS sessions One of the undocumented options in SAS 6.12 which PROC OPTIONS INTERNAL reveals is: –$logflush … closes LOG after each line is written Very useful for looking at log during non- interactive runs Usually can’t see log until the SAS session finishes

19
Speed up your SAS programs Use o/s commands for copying & deleting –They are much quicker than SAS alternatives –Execute o/s commands asynchronously Clean up work space during job –Large work datasets should be deleted by you when they are no longer needed, otherwise they may take valuable space Clean up memory every so often –Use CDE P to purge unused modules from memory

20
More ways to speed things up Split data into smaller bits for sorting –Especially if they can fit in memory –Saved 36% in one example Sort or index on a compressed single key Reduce I/O contention –Put work, swap and data on different physical disks where possible

22
Building long selection lists in SQL Even in v6 macro variables may be up to 32k long Useful to store long text strings, such as variable lists –e.g. Can make a list of employees in one dataset to select from another Code

23
Where on Output dataset Where clauses can be used for filtering data Usually they are used with input data They can be used with output data too output Keeping selected _type_ values

26
Any questions? If so, please see me afterwards since I am probably out of time.

27

28
When is 3 * 1/3 not 1 Numbers within SAS are handled with floating point arithmetic data _null_ ; a=1/3 ; b=3*a ; c=1-b ; put b= c= ; Run ; Produces B=1 C= E-17 Fails due to floating point arithmetic being inexact Get around it by using round function, or FUZZ in PROC FORMAT

30
& versus && versus &&& In Base SAS –&name refers to a macro variable called name –&&name is scanned twice by macro processor –&&&name is treated as &(&name) CodeCode If used in SCL – SAS/AF –&name tries to substitute SCL variable name, if it exists If it does not exist, then it looks for a macro variable called name –&&name is useful since it doesn’t try to substitute an SCL variable even if one exists of that name, but uses the macro variable –&&&name works as in Base SAS

31
Proc Printto to redirect and process log Can redirect procedure output or LOG to a catalog member or external file Useful for saving log and then analysing it proc printto log=work.test.test.log ; run ; proc printto print='c:\print.lst' ; run ; proc print data=sasuser.houses; run ; proc printto print=print ; run ;

32
Use attrib for common definitions To produce a PROC PRINT without any labels you can set them to null values You may try the following, but it does not work since you can’t use _all_ in LABEL statements proc print data=datatran.emptypev label noobs; label _all_='00'x; run; You can use the ATTRIB statement which does support _ALL_ - this code works proc print data=datatran.emptypev label noobs; attrib _all_ label='00'x; run;

33
Searching program editor or log for macro variables If you simply enter &macname in the FIND box, it will resolve &macname before looking To search for the unresolved reference search for: %nrstr(&macname) –%nrstr(&macname) resolves to &macname.

34
Data step views for parsing text files to extract info Useful if you have regular flat file data you want to process with SAS Just define a view Data monthly / view=monthly ; Infile ‘c:\monthly.txt’ ; Input name $30. Address $30. ; Run ; Can use view as input to other data steps and procedures and data will always be fresh, e.g. Proc report data=monthly ; run ;