Obsah 1. Úvod do SAS EG 3 2. Pokročilé programování v SAS 50 3. Pokročilé programování v SAS - indexy,... 172 4. Credit scoring (CS) - historie, základní pojmy. 304 5. Metodologie vývoje scoringových funkcí. 346 6. Příprava dat II. 418 7. Úvod do shlukové analýzy. Hiearchické shlukování. 466 8. Vývoj CS modelu. 529 9. Úvod do analýzy přežití. 585 10. Coxova regrese. 636 11. Evaluace modelu II. 652 12. Stanovení cut-off. RAROA, CRE. Monitoring. 697 13. Reference. 733 1. Úvod do SAS EG Introduction to SAS Enterprise Guide •SAS Enterprise Guide provides a point-and-click interface for managing data and generating reports. Summary Statistics for S:\workshop\customers.sas7bdat Data Statistics Basic Percentiles Additional Plots Results Titles Properties Data source: S:\workshop\custonners.sas7bdat Task filter: None Variables to assign: Task roles: Name CustomerJD ^ Customer_Country ^ Customer_G ender Customer_N ame ^ Customer_FirstName ^ Customer_LastName Customer_BirthDate ^ Customer_Age_G roup Customer_Type ^ Customer_G roup (2> Customer_Age [ffil Analysis variables Customer_Age Classification variables Frequency count (Limit: 1) Relative weight (Limit: 1) Copy variables Group analysis by Class level Customer_ Sort by: Unformatted values Ascending Missing values: I I Allow multi-label for The variables that you assign to this role are character or discrete numeric variables that are used to divide t data into categories or subgroups. The statistics will be calculated on all selected analysis variables for e. combination of classification variables. Bar Chart for S:\workshop\orion_profit.sas7bdat 3 of A Specify appearance 0 3D chart Colors - Sample chart: Color bars by: Labels I Bar category Preview code HE t\ae t eachl 3 I I Legend: 0Data labels: Lines and ticks South Sum Anis Labels W] Use reference lines [^1 Tick marks §sas SAS Enterprise Guide Interface SAS Enterprise Guide also includes a full programming interface that can be used to write, edit, and submit SAS code. ^ SAS Enterprise Guide File Edit View Tasks Project Tree Q S^n Process Flow 3'"i^l orion_profit fe|$ Bar Chart customers □~CD Programs jM ep02d01 Program Tools T x ep02d01 - Help "a-&T ¥^ R=) CB X I W> l3< I □ " I Process Flow Output Data (2) Program y 5ave " w Run " itop 5elect 5erver Export " 5end To - Create " | [?] Properties libnarne orion "s:\workshop' set orion.customers; if Customer_Type_ID = 3010 then output work.nonelub; else output work. clubrnembers; 1 2 3 13 data work. c lubrnembers work. none lub; 4 5 6 7 8 9 lOBproc print data=work.nonelub noobs; 11 title "Non Club Members"; var Country Gender Custorner_Name; 13 run; 14 run; SAS Enterprise Gu ide Interface: The Project •A project serves as a collection of • data sources • SAS programs and logs • tasks and queries • results • informational notes for documentation. SAS Enterprise Guide - e101a01 .egp File Edit View Tasks Program Tools l=j-E^g Process Flow \ I=l"i3 0RI0N_PR0FIT [H Product Frequencies W'> Profit by Category Pie Chart |y] Profit by Country/AgeGroup Report - Create Format ($CntryFrnt - Local) Link to Create Orion_Profit El [__J Programs £)'"[[§ Create Drion_Profit □ -Lgj Custom Reports [C| Report Help I Ü ' £Sr Process Flow » Task List - x W|CS I ® Tasks by Category Data Filter and Sort _ §1§ Query Builder Append Table prld Create Imported Format H Sort Data Sid Create Format < > Ready You can control the contents, sequencing, and updating of a project. SAS Programs data work.clubmembers work.nonclub;^ set orion.customer; if Customer_Type_ID = 3010 then output work.nonclub; else output work.clubmembers; run ; proc print data=work.nonclub; title "Non Club Members"; var Country Gender Customer_Name -run ; DATA Step PROC Step ep02d01.sas 7 PROC PRINT Output 5sa Enterprise Guide- The Fkruver tftKiww-Non Club Members Obs Country Gender Customer_Name 1 DE M Ulrich Heyde 2 US M Tulio Devereaux 3 US F Robyn. Klera 4 us F Cynthia Mccluney 5 AU F Candy Kinsey 6 US M Phenix. Hill 7 IL M Avinoam a we ig" 8 CA F Lauren Marx Saving SAS Programs •The SAS program in the project is a shortcut to the physical storage location of the .sas file. Select the program icon and then select File O Save program name to save the program as the same name, or Save program name As... to choose a different name or storage location. _ SAS Enterprise Guide File Edit View Tasks Program New "J Open Close Project ► ► 5ave Project 5ave Project As... Ctrl+5 y 5ave ep02d01 Ctrl+Shift+S IE Save ep02d01 As... Embedding Programs in a Project •A SAS program can also be embedded in a project so that the code is stored as part of the project .epg file. •Right-click on the Code icon in a project and select Properties O Embed. a3 Properties for ep02d01 General Results Prompts Summary General Label: ep02d01 Code will run on server: Local Last Execution Time: 2 seconds File path: Change.. Location: My Computer Embed 1¥ Save As.. Embeds the code in the SAS Enterprise Guide project so that any changes that you make to the code in SAS Enterprise Guide are not applied to the original code file. This option is available only for existing code files that you have inserted into yr1 □ K More (F1)... Cancel 10 How Do You Include Data in a Project? File Edit View Tasks Program '=1 New Tools Help I HI -Process Flow [?=t Open Close Project 5ave Project 5ave Project As. 5ave F igfl Project Ctrl+O SAS Enterprise Guide Ctrl+ File Edit View Tasks Program Tools Selecting File ■=> Open o Data adds a shortcut to a SAS data source in the project. Project Tree Process FlowA □ S^c Process Flow order_itern Pun Stop order_itern 11 Assigning a Libref •You can use the Assign Project Library task to define a SAS library for an individual project. SAS Enterprise Guide File Edit View Tasks Program Tools Help |H~|^r^&| =) Oi ?\ I I n» | E^g Process Flow ^ Project Tree ^ D Add-In □ S^g Process Flow Create HTML Document... Style Manager " I Zoom " "^Project Log | [^Properties » U 1_1 i luyiain-^ ep02d01 £J ep02d02 Assign Project Library... JMP Stored Process Packager.. Project Maintenance.., View Open Data Sets... ■_■ i ■_■ i ij HTML ep02d0 1 Browsing a SAS Library Server List H~W LLB Inventory Local Ö-|3) Libraries + $■ (=)■ •During an interactive SAS Enterprise Guide session, the Server List window enables you to manage your files in the windowing environment. In the Server List window, you can do the following: ■ view a list of all the servers and libraries available during your current SAS Enterprise Guide session ■ drill down to see all tables in a specific library ■ display the properties of a table ■ delete tables ■ move tables between libraries GISMAPS MAPS MYDATA ORION TJ ALL_SUPPLIERS AUSTRALIA_SUPPLIERS QJ COMBINED_PRODUCT [3 CUSTOMER [3 CUSTOMER_PROFIT jJJ CUSTOMER_TYPE [3 EMPLOYEE_CELL |3 EMPLOYEEJHOME |3 MNTH7_2007 [3 MNTHS_2007 [3 MNTH9_2007 TJ NONSALES jg NORTH_AMERICAN_SUPFLIERS 13 Applying Formats Display formats can be applied in a SAS Enterprise Guide task or query by modifying the properties of a variable. Task roles: I List variables ^) EnnploiieeJD ■jfci. First_Nanne ■jfä^ Last_Narne (;Ti) ff^JB'111 (j3) Bonus ^) Cornpens ^) BonusMq Group analysl | ^ | Page by (LimJP Total of Subtotal of Identifying laBeT Remove from Role 5ort Columns Show Names 5how Labels Properties Ír Categories: Formats: None Numeric Time Date/Time Currency User Defined All MMDDYYSw.d_ai| MMDDYYw.d MMYYCw.d MMYYDw.d MMYYNw.d ._■ MMYYPw.d MMYYSw.d MMYYw.d ■Attributes -Overall width: Decimal places: IS" 3J Min: 2 Max: 10 |Ö~~ ~~3 Min: 0 Max: 7 "Description date values "Example Value: 14245 (01Jan1999] Output: 0 1 / 0 1 / 9 9 OK Cancel 14 Query Builder Join •When you use the Query Builder to join tables in SAS Enterprise Guide, SQL code is generated. SQL does not require sorted data. SQL can easily join multiple tables on different key variables. SQL provides straightforward code to join tables based on a non-equal comparison of common columns (greater than, less than, between). "!:: Query Builder for Local: ORION. ORD ERJTEM Query name: Join for Product List] Output name: |SASUSER.QUERY_FOR_ORDER_IT | | Change... H] Computed Columns | @ Prompt Manager Tc^ Preview | Tools Options " } Add Tables X Delete Join Tables ■ © o © © © ■ © © © © ORDERJTEM) □ rder_ID Order_ltem_Num Product_ID Quantity Total_Retail_Price CostPrice_Per_U nit Discount PRODUCTJJST ) Product_ID Product_Name Supplier_ID Product_Level Product Ref ID Select Data | Filter Data| Sort Data] Column Name Input Summary ® OrderJD [Order... tl.OrderJD H @ Order_ltem_Num... t1 .OrderJtem_Num ® ProductJD (Pro... H.Product ID ® Quantity (Quantit... H .Quantity *f* Total_Retail_Pri... H.Total Retail Price ^ CostPrice_Per_... tl.CostPrice Per ... @ Discount (Disco... tl .Discount © ProductJD 1 (Pr... t2. ProductJD ^ ProductJJame (... t2. Prod uct_N arme © SupplierJD (Sup... t2. SupplierJD @ ProductJ_evel (... t2.Product Level @ Product_Ref_ID ... t2.Product Ref ID > Ml m a I I Select distinct rows only Run Save and Close Cancel Help 15 Sort Data Task •The Sort Data task enables you to create a new data set sorted by one or more variables from the original data. Ü Sort Data for Local:ORION.PRODUCT_L 1ST Options Results Properties Data Data source: Local:ORION.PRODUCTJJST Task filter: None Edit.. Columns to assign: Task roles: ProductJD sort order: Name ® ProductJD $1 Product_Name © SupplierJD ® Product_Level ® Product_Ref_ID | Sort by ■@ ProductJD | Columns to be dropped (Limit: A l±J Ascending O Sort Data for Local:ORION.PRODUCT LIST Data Options Results Properties Results r~ Location to save output data- Local: WORK. SORT PRODUCT Browse... Business Scenario •Orion Star wants to send information about a specific promotion to female customers in Germany. The report can be created by querying the or ion. customer data set to include only the desired customers, and then by producing a report with the List Data task. CUSTpMEFf remale German F_G errmanv List Da:a HTML Female Customers in Germany Customer Country Customer First Name Customer Last Name Customer Birth □ate DE Co rnelia Krahl 27FEB1974 DE Elke iallstab 16AUG1974 DE Ines Deisser 20JUL1969 Business Scenario •The same report can be generated more efficiently by subsetting the data directly within the List Data task. This requires modification of the code generated by SAS Enterprise Guide. CUSTOMER List Data -HTMM-List Data 2 7 □ PRÜC PRIHT DATA=WORK. SORTTempTableSorted 2 8 NOOBS 29 LABEL 30 ; 31 _ 32 33 34 35 3 6 VAR Country Customer_FirstName Customer_LastName Birth_Date; 3 7 RUH; /* Start of custom user code. */ where Country = 1DE1 and Gender = 1F1; /* End of custom user code. */ 38 /*------------------ 39 End of task code. 40 41 RUH; QUIT; 18 Understanding Generated Task Code •There are many situations where task results created by SAS Enterprise Guide can be further enhanced or customized by modifying the code. •However, before you can effectively modify the code, you must first understand the code that SAS Enterprise Guide generates. List Data Task H List Data for Local:ORION.CUSTOMER Data Options Titles Properties Preview code Data Data source: Task filter: LocahORION.CUSTOMER None Edit.. Variables to assign: Task roles: Gender sort order: Name 1^3) Customer_ID fy. Country ^.Gender ^PersonalJD fy. Customer_Name fy. Customer_FirstName fy. Customer_LastName Q Birth_Date fy> Customer_Address © StreetJD $L Street_N umber @) Customer_Type When yo^assign one or is generated for each dis List variables Country Customer_FirstName Customer_LastName -H Birth_Date Group analysis by Page by (Limit: 1 ] Total of Subtotal of (Limit: 1] Identifying label Ascending 0 Sort by variables The Preview code button enables you to view and modify the code generated by the task. ng Run Save Cancel Help List Data Task - Code Preview Code Preview For Task Insert Code.. I Code generated by SAS Task Generated on: Wednesday, April 29, 2009 at 11:12:29 AH By task: List Data Input Data: ORION.CUSTOMER Server: Local % eg coitd±t±oital diopds (WORK. SORTTempTab leSorted) ; /*------------------------------------------------------------------- Sort data set ORION.CUSTOMER ------------------------------------------------------------------- */ □ PROC SORT DATA=ORION. CUSTOMER (KEEP = Country Custorner_FirstNaroe Customer_LastName Bin OUT=UORK. SORTTempTableSorted BY Gender; RUM;_ TITLE; TITLE 1 "Report Listing"; FOOTNOTE; TT" TT,TTTT" H FFf1 Using the List Data Task to Generate Code •This demonstration illustrates building a List Data task and examining the code generated by SAS Enterprise Guide. Customer Listing Customer Gender=F Customer Customer First Customer Last Name Customer Birth Country Name Date US Sandrina Stephano 09JUL1979 DE Cornelia Krahl 27FEB1974 US Karen Ballinger 1BOCT19B4 DE Elke Wallstab 16AUG1974 Customer Gender=M Customer Country Customer First Name Customer Last Name Customer Birth □ate US James Kvarniq 27JUN197 4 us David Black 12APR1969 DE Markus Sepke 21JUL1988 DE Ulrich Heyde 16JAN193 9 22 List Data Task - Generated Code •The initial comment block shows information about the task. /*---------------------------------------------------------- Code generated by SAS Task Generated on: Wednesday, April 29, 2009 at 1:13:33 PH By task: List Data Input Data: ORION.CUSTOMER Server: Local ------------------------------------------------------- */ 23 List Data Task - Generated Code •The first line uses a macro to delete temporary tables or views if they already exist. If the Group by role is used in the task, the data must be ordered by the grouping variable. PROC SORT is used by default. Only variables assigned to roles are kept in the new data set. h eg cofldl t± on a Id ±op d & (WORK ■ S ORTTernp Tab leSorted) ; /*--------------------------------------------------------- Sort data set ORION.CUSTOMER ------------------------------------------------------ V PROC SORT DATA=ORION.CUSTOMER(KEEP=Country Custonier_FirstName Custonier_LastName Birth_Date Gender) OUT=UORK.SORTTempTataleSorted ■ BY Gender; RU1I; List Data Task - Generated Code If the Group by role is not used, SQL creates a temporary view of the required data. Again, only variables assigned to roles in the task are included in the view. This comment incorrectly states that sorting occurs. h eg aon Run " □ 5top Export - Schedule Open l> Run List Data HI Modify List Data Select Input Data Publish,,,_ I Open List Data I Open Last Submitted Code Zoom Open Log Process Flow b- Run I Stop I Export T Schedule CUSTOMER List Data ■ I Zoom MTMI - ■ Project Log | f/) Properties Open Run Modify List Data Run Branch from List Data T-l--■■ T---- -a pj Open List Data [SI Open Last Submitted Code \=M Open Log 0 HTML - List Data Edit Last Submitted Code The task code is read-only and cannot be edited directly To create a copy of the code from the Last Submitted Code window, select any key while in the SAS program window. SAS Enterprise Guide offers to make a copy. SAS Enterprise Guide This code is read-only. Do you want to create a copy of this code that can be modified? Yes No After the code is copied, there is no link between the task and the new code. Any changes in the task are not reflected in the copied code, and modifications to the code do not affect the task. Summary of Editing Last Submitted Code Custom code linked to task? No Can be used to modify query code? Yes Extent of modification allowed? Anything in the program can be changed. Custom code included when exported? Yes. You must export the edited program and select the option in the Export wizard. Automatically Submit Custom Code Before or After Every Task and Query •There are times when you might need to run a SAS statement or program before or after any task or query is executed. The Custom Code option enables you to insert custom code before or after all tasks and queries. 32 Automatically Submit Custom Code Before or After Every Task and Query •IT General Project Views Project Recovery Results Results General Viewer SAS Report HTML RTF PDF Graph Stored Process Data Data General Performance Query □ LAP Data Tasks Tasks General Custom Code Tasks > Custom Code ■Additional SAS code- [^1 Insert custom SAS code before task and query code ^ Insert custom SAS code after task and query code To run code before tasks and queries, select the first check box and select Edit... to type the code. Edit Edit. 33 Automatically Submit Custom Code Before or After Every Task and Query Global statements or complete program steps can be entered. Example: Set the LOCALE= option to Great Britain. Edit /* Insert custom code before task code here */ OPTIONS LOCALE=en GB; nsert Code Before or After SAS Programs •Similar options exist to automatically submit code before or after SAS programs written and submitted in Code windows in SAS Enterprise Guide. General Project Views Project Recovery Results Results General Viewer SAS Report HTML RTF PDF Graph Stored Process Data Data General Performance Query OLAP Data Tasks Tasks General Custom Code Output Library SAS ProgramsK Security § SAS Programs r General 0 Automatically direct results back to SAS Enterprise Guide 3 Close all open data before running code Editor Options.. r Additional SAS code [^1 Insert custom SAS code before submitted code [^1 Insert custom SAS code after submitted code ] Submit SAS code when server is connected Edit. Edit... Edit... Summary of Submitting Custom Code Before or After Every Task and Query Custom code linked to task? Yes Can be used to modify query code? Yes Extent of modification allowed? Statements can only be submitted before or after the task code. Custom code included when exported? Yes, select the option in the Export wizard. Insert Custom Code in a Task •In most task dialog boxes, you have the ability to insert custom code within the generated SAS program. This technique has the significant benefit that the task interface can still be used to modify the report. 13 w lor Tas Insert Code.. 2 7 □ PROC PRINT DATA=WORK. SORTTempTab leSot^ted 28 OBS="Row number" 29 LABEL 30 ; 3 1 32 33 34 35 3 6 /* Staut of custom usee code. where country="DE"; ^^^En^^of^custo^j^iser^codej^^^ 7 VAR Country Customer FirstName Customer LastName Birth Date; RUH; .a 37 /*----------------- 38 End of task code 39 Insert Custom Code in a Task •In the Code Preview window, select Insert Code... to add custom code in predefined locations in the SAS program. Code Preview For Task Insert Code. 21 ! /*------------------------------------------------------ 2 Code generated toy SAS Task 3 4 Generated on: Thursday, March 13, 2008 at 10:57:50 PM 5 By task: List Data 6 7 Input Data: ORION.CUSTOMER 8 Server: Local 10 HBPROC SQL; 12 %_£A£TA£K_BFtGPDS (WORK. SORTTennpTab leSorted) ; 13 QUIT; nsert Custom Code in a Task User Code Positions where user code may be inserted are indicated by the icons. Double-click on a marked line to add user code or change existing user code. V PROCSQL; CREATE VIEW WORK.SORTTempTableSorted AS SELECT Country, Custorner_FirstName, Custorner_LastNarne, Birth_Date FROM ORION.fl^BffMER; QUIT; TITLE; TITLE1 "Report Listing"; FOOTNOTE; F00TN0TE1 "Generated by the SAS System (&_SAS SERVER NAME, E.S^ffCJfl' oy^rVSFUNC(DATE(), EL i Clear All OK Cancel Help 39 nsert Custom Code in a Task Some insert points enable custom options to be added to existing statements. User Code 0® Positions where user code may be inserted are indicated by the icons. Double-click on a marked line to add user code or change existing user code. PROC PRINT DATA=W0RK.S□ RTTempTableSorted, □ BS="Row number" LABEL -Ji, RUN; , r End of task code. V RUN;QUIT; i PROC SQL; %_SASTASK_DROPDS(WORK.SORTTempTableSorted); QUIT; TITLE; FOOTNOTE; , > Clear All OK Cancel Help 42 Default SAS Enterprise Guide Footnote Options General Project Views Project Recovery Results Results General Viewer SAS Report HTML RTF PDF Graph Stored Process Data Data General Performance Query OLAP Data Tasks Tasks General Custom Code Tasks > Tasks G General— Default title texj/or task oi The default footnote includes macro references to the SAS server name, operating system, and date and time that the task runs. Default |ootnote text for task output: ^Djsgla^^l^ejTe^ated^AS^odejnJa^k Generated by the SAS System version &SYSVER (&_S AS SERVERNAME, &SYSSCPL) on %TRIM (%QSYSFUNC (DATE () , NLDATE20 . ) ) at %TRIM(%SYSFUNC(TIME() , NLTIMAP20 . ) ) 43 ODS and SAS Enterprise Guide Default result formats can be set under Tools O Options SI Options General Project Views Project Recovery Results Results General Viewer SAS Report HTML RTF PDF Graph Stored Process Data Data General Performance Query □ LAP Data Tasks Tasks General Custom Code Output Library SAS Programs Security Administration Results > Results General ■ Result Fomnats- 0 SAS Report □ RTF Default: □ html I I Text output □ PDF SAS Report ■Managing Results-Replace results: Prompt before replacing 0 Display SAS log when errors occur 0 Automatically open data or results when generated 0 Link handcoded ODS results 0 Change task icon when warnings occur 0 Show generated wrapper code in SAS log Prompt before opening results larger than: MB Maximum number of output data sets to add to the project: 50 ODS and SAS Enterprise Guide •Additional settings can be made for each result format. General Project Views Project Recovery Results Results General Viewer SAS Report HTML Stored Process Data Data General Performance Query □ LAP Data Tasks Tasks General Custom Code Output Library SAS Programs Security Administration Results > PDF Appearance-Style: printer Columns: 0 Color 0 Add Bookmarks f File Header-Author: Keywords: Subject: Title: Advanced- Additional options for ODS PDF statement: ODS and SAS Enterprise Guide • Task properties can be used to override the default for an individual task. • Generated output can be switched off completely and handled by inserting code. PrornptsU^ Summary Right-click on a task icon and select Properties. EGDefault O Use preferences from Tools -> Options HTML - EGDefault (*) Customize result formats, styles, and behavior □ SAS Report 0 HTML □ PDF □ RTF □ Text Graph Format: H ActiveX EGDefault printer Rtf □ Automatically open data or results when generated Reset Options The selection pane enables you to select a category of options to view. More (F1)... □ K Cancel SAS Enterprise Guide Help (Review) •If Help files were installed along with SAS Enterprise Guide, you can select Help to access the Help facility regarding both the point-and-click functionality of SAS Enterprise Guide as well as SAS syntax. & SAS Enterprise Guide File Edit View Tasks Program Help H - (är 35 Si^iS Project Tree ▼ SAS Enterprise Guide Help SAS Syntax Help Getting Started Tutorial ■S^o Process Flow SAS on the Web ► About SAS Enterprise Guide k 1 Task and Procedure Help E? SAS Enterprise Guide Help Hide Back Print Contents Index Search Favorites Type in the keyword to find: I list data List Data task List Report wizard log entries collapsing and expanding log properties LOGISTIC procedure Logistic Regression task To find information regarding the syntax of the code behind the scenes of a particular task, type the name of the task in the Index tab. Display 5 List Data About the List Data task The List Data task prints the observations in a SAS data set, using all or some of the variables. You can create a variety of reports, ranging from a simple listing to a highly customized report that groups the data and calculates totals and subtotals for numeric variables. For example, you can use the Lis report that sums the expenses a sales region, compares these va expenses and revenues for the c number of observations in each ; whole report, and has a customi name of the region. ► Assigning variables to analysis ► Setting listing options ► Specifying titles and footnot ► Viewing properties The task help indicates the procedure name to search in the SAS syntax help. SAS procedures used PRINT Required SAS products ^aase^Ksr^ Recommended additional none SAS products J 48 Procedure Syntax Help Jp. SAS Documentation File Edit View Go Help Hide Locate Back Forward O Stop Refresh Print Options Contents Inden Search Favorites 9 ft The PLOT Procedure + ft ThePMENU Procedure □ s The PRINT Procedure \^} Overview: PRINT Procedure |i] PROC PRINT Statement |] BY Statement ^ ID Statement |] PAGEBY Statement |] SUM Statement D SUM BY Statement ff) VAR Statement \^\ Results: Print Procedure B ft Examples: PRINT Procedure 9 The PRINTTO Procedure + ft The PROTO Procedure + ft The PRTDEF Procedure El ft The PRTEXP Procedure 9 ft TheFWENCODE Procedure B ft The RANK Procedure B ft The REGISTRY Procedure S ft The REPORT Procedure + ft The SCAPROC Procedure B ft The SOAP Procedure + ft The SORT Procedure + ft Ttle SQL Procedure B ft The STANDARD Procedure + ft The SUMMARY Procedure a ft The TABULATE Procedure + ft The TEMPLATE Procedure a ft The TIMEPLOT Procedure B ft The TRANSPOSE Procedure + ft The T RAN TAB Procedure B ft The UNIVARIATE Procedure Previpus Page | Next Page The PRINT Procedure Syntax: PRINT Procedure Tip: Supports the Output Delivery System. See Output Delivery System: Basic Concepts in SAS Output Delivery System: User's Guide for details. Tip: You can use the ATTRIB, FORMAT, LABEL, and WHERE statements. See Statements with the Same Function in Multiple Procedures for details. You can also use any global statements. See Global Statements for a list. Table of Contents: The PRINT Procedure PROC PRINT ; BY variable-1 <... variable-nxNOTSORTEDo; PAGEBY BY-variable, SUM BY BY-variable, ID variable(s) ... >)); • jf For increased efficiency, use the INDEX= option to create indexes when you initially create a SAS data set. Viewing Information about Indexes • To display information in the log concerning index creation or index usage, change the value of the MSGLEVEL= system option from its default value of N to I. • General form of the MSGLEVEL= system option:_ OPTIONS MSGLEVEL=N | I; 11 options msglevel=i; 12 data orion.sales_history(index= 13 (Customer_ID Product_Group 14 SaleID=(Order_ID 15 Product_ID)/unique)); 16 set orion.sales_history; 17 run; NOTE: There were 1500 observations read from the data set ORION.SALES_HIST0RY. NOTE: The data set ORION.SALES_HIST0RY has 1500 observations and 22 variables. NOTE: Composite index SaleID has been defined. I_ NOTE: Simple index Product_Group has been defined. NOTE: Simple index Customer_ID has been defined. Creating an Index with the INDEX= Data Set Option Advantages Disadvantages You can create the data set To create an additional index, and the index in one step. you must re-create the existing indexes. SAS only reads the data once. You need to know in advance that indexes are needed. Managing Indexes with PROC DATASETS options msglevel=n, > proc datasets library=orion nolist; modify sales history; index create Customer ID; index create Product Group; index create SaleID=(Order ID Product ID)/unique; quit; The following code would delete the indexes: proc datasets library=orion nolist; modify sales_history; index delete Customer_ID Product_Group SalelD; quit; p303d02 Managing Indexes with PROC DATASETS • You can use the DATASETS procedure on existing data sets to create or delete indexes. • General form of the PROC DATASETS step to delete or create indexes: PROC DATASETS LIBRARY=//£/-efNOLIST; MODIFY SAS-data-set-name, INDEX DELETE index-name, INDEX CREATE index-specification < / options>) QUIT; 3.04 Quiz • Open and submit the program p303aoi. • What error messages are in the log? options msg] .evel=n ; proc dataset :s library=orion nolist; modify Sc lies history; index create Customer ID; index create Product Group; index create SaleID=(Order ID Product ID)/unique; quit ; p303a01 3.04 Quiz - Correct Answer 1 options msglevel=n; 2 proc datasets library=orion nolist; 3 modify sales_history; 4 index create Customer ID; ERROR: An index named Customer ID with the same definition already exists for file ORION.SALES_HIST0RY.DATA. 5 index create Product_Group; 6 index create SaleID=(Order_ID 7 Product_ID)/unique; 8 quit; NOTE : Statements not processed because of errors noted above. NOTE : The SAS System stopped processing this step because of errors. NOTE : PROCEDURE DATASETS used (Total process time): real time 0.48 seconds cpu time 0.09 seconds ^ If an index exists, it must be deleted before it can be re-created. Managing Indexes with PROC DATASETS Advantages Disadvantages Additional indexes can be created without re-creating the original indexes. You can only create indexes on existing SAS data sets and existing variables. One or more indexes can be PROC DATASETS cannot perform deleted without deleting all of the data manipulation, indexes on the data set. If an index exists, it must be deleted before it can be re-created. Managing Indexes with PROC SQL options msglevel=n; proc sql; create index Customer_ID on orion.sales_history(Customer_ID); create index Product_Group on orion.sales_history(Product_Group); create unique index SalelD Name of Index Variable Name on orion.sales history(Order ID, Product ID); quit; • The following code would delete the indexes: proc sql; drop index Customer ID, Product Group, SalelD from orion.sales history; quit; p303d03 Managing Indexes with PROC SQL • You can use PROC SQL on existing data sets to create or delete indexes. • General form of the PROC SQL step to create or delete indexes: PROC SQL; DROP INDEX index-name FROM table-name, CREATE