![]() |
||||||||||
|
SAS ENTERPRISE GUIDE EXPERT SHARES A HINT FROM HIS NEW BOOKSAS modules addressed: Enterprise Guide Today, many people use SAS Enterprise Guide as their main tool for getting to the power of SAS. With almost no product training complex data manipulation, reporting, graphical output and statistical analysis are within easy reach. In this article, I'll show you how to expand the power of SAS Enterprise Guide with just a minimal amount of coding. Let's look at an example which can reduce run times by inserting a WHERE statement, similar to a filter in the 'filter and query' task, into another task. Eliminating the need for some filter and query tasks. Create a project and add the SASHELP.CLASS data set to it. Create a List Data task linked to it with all of the columns assigned to the List variables role. Click the Preview code button, and from there click the Insert Code button.
The diagram above shows where code of various types can be inserted in this task. The WHERE statement can be put it at any of the places shown as suitable for inserting statements. Double-click on any of the points we have identified as suitable for our WHERE statement to open the code editor window, and then enter the following statement: WHERE Sex = "F"; Click OK on the Enter User Code window and again on the User Code window. Before leaving the Code Preview window, find the code you just inserted and check that the color coding is as expected. Especially look for anything in red, which shows that the code has been entered incorrectly. Then close the Code Preview code window and run the task. You should now see only female class members listed. Go back into the task and make any changes you want to in terms of grouping, headings and footings, formats, or other options. You can even remove some columns if you want. Then run the task just to verify the output. The expression on the WHERE statement can be anything that you can put on a filter in a query. The advantage of using the WHERE statement is its efficiency. If you subset your data by using a query first, then you are creating an extra copy of the data, which takes time and disk space. It might not matter on data this small, but if you are working on a few million records, the savings could be significant. Though we have used a List Data task for our example, almost any task allows the use of the WHERE statement. This example is one of many in my new book 'SAS Programming for Enterprise Guide users', a book being published in November by SAS Press. Other techniques include highlighting data based on value, dynamic file names, improved titles and footnotes, and report and graph linking. If you want be kept informed of new SAS Press releases, including 'SAS Programming for Enterprise Guide users', then visit http://support.sas.com/publishing/ and select the 'Available Soon!' menu item. Books from SAS Press can be purchased on-line from www.amazon.co.uk Neil Constable, SAS Education Did you find this page useful?If you have any comments or questions, feel free to contact us. |
|
||||||||