evropský sociální fond v ČR EVROPSKÁ UNIE MINISTERSTVO ŠKOLSTVÍ, MLÁDEŽE A TĚLOVÝCHOVY OP Vzdělávání pro konkurenceschopnost INVESTICE DO ROZVOJE VZDĚLÁVÁNÍ Tento učební text vznikl za přispění Evropského sociálního fondu a státního rozpočtu ČR prostřednictvím Operačního programu Vzdělávání pro konkurenceschopnost v rámci projektu Univerzitní výuka matematiky v měnícím se světě (CZ.1.07/2.2.00/15.0203). Obsah: 1. Úvod do SAS EG 4 2. Pokročilé programování v SAS 51 3. Pokročilé programování v SAS - indexy,... 173 4. Credit scoring (CS) - historie, základní pojmy. 305 5. Metodologie vývoje scoringových funkcí. 347 6. Příprava dat II. 419 7. Úvod do shlukové analýzy. Hiearchické shlukování. 467 8. Vývoj CS modelu. 530 9. Úvod do analýzy přežití. 586 10. Coxova regrese. 637 11. Evaluace modelu II. 653 12. Stanovení cut-off. RAROA, CRE. Monitoring. 713 13. Reference. 749 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: 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 Analysis variables Customer_Age FH Classification variables ^RuS Custorner_Type Frequency count (Limit: 1) ffil Relative weight (Limit: 1) B Copy variables B Group analysis by H 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 §sas 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 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 Q Process Flow S El 0RI0N_PR0FIT H Product Frequencies Wi Profit by Category Pie Chart |; 1 Hrotit by Countiy/Agebioup Report Q 53* Create Format ($CntryFmt ■ Local) Link to Create Orion_Profit Q Cj Programs E) j|J Create Orion_Profit B Qi) Cuslom Reports ^ Report Help "Ü - reprocess Flow - C|^| [fa, X I CM I Process Flow > Run -r Q Export ▼ Schedule - | Zoom - | ^ Project Log | [7] Properties Tasks by Category Sw. Filter and Sort Query Builder Append Table !d Create Imported Format Sort Data J 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; print data=work.nonclub; title "Non Club Members"; var Country Gender Customer Name* run ; DATA Step PROC Step ep02d01.sas 8 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... 10 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. Properties for ep02d01 Results Prompts Summary 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 yr^r "'"^j □ K Cancel 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 12 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_SUPPLIERS 14 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 ^) EmploiieeJD ■jfci. First_Nanne ■jfä^ Last_Name (;Ti) ff^JB'111 (j3) Bonus ^) Compens ^) BonusMq Group analysl | ^ | Page by (LirrJP 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: |Š~~ 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 15 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.Product_Name © 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 16 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_Narne © 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 (^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. CU5TKiMEF[ remale German F_G ermanv 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_LastWame 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; 19 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) Custorner_ID fy. Country ^.Gender ^PersonalJD fy. Custorner_Name fy. Custorner_FirstName fy. Customer_LastName Q Birth_Date fy> Custorner_Address © StreetJD $L Street_N umber @) Custorner_Type When yo^assign one or is gendered 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,TT"TT" 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 23 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 ------------------------------------------------------- */ 24 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 TITLE and FOOTNOTE are examples of global statements and can be included anywhere in a SAS program. on hTRIM(%QSYSFUNC(DATE(), NLDATE2□.)) at % TRIM(% SYSFUNC(TIME[) f NLTIHAP2□.) ) rr . 27 List Data Task - Generated Code •At the end, the final lines of code delete any temporary tables created to build the task, and delete any assigned titles and footnotes. /*--------------------------------------------------------- End of task code. ------------------------------------------------------ */ RUN; QUIT; %_eg_cojidit±onal_djropds (WORK. SORTTempTab leSorted) ; TITLE; FOOTNOTE; 28 Techniques to Modify Code •Three methods can be used to modify code generated by SAS Enterprise Guide: 1. Edit the last submitted task code in a separate Code window. 2. Automatically submit custom code before or after every task and query. 3. Insert custom code in a task. 29 Edit Last Submitted Code •After a task runs, the code can be viewed from either the Project Tree or Process Flow. SAS Enterprise Guide File Edit View Tasks Program Tools Help I ,ä ^ ^ XI* Project Tree S S^g Process Flow CUSTOMER List Data Process Flow t> Run " □ 5top Export - Schedule Open i> Run List Data [TJ 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 | [?] 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. 33 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. 34 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^ffSFUNC(DATELl EL i Clear All OK Cancel Help 40 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 43 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 n i irni ih I ihrjan i Tasks > Tasks G General— Default title texj/or task or 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: ^DjsoJa^^l^ejTe^a^e^^AS^odejnJa^k^u^gu^ Generated by the SAS System version &SYSVER (&_S AS SERVERNAME, &SYSSCPL) on %TRIM (%QSYSFUNC (DATE () , NLDATE20 . ) ) at %TRIM(%SYSFUNC(TIME() , NLTIMAP20 . ) ) 44 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 Formats- 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. O Use preferences from Tools -> Options HTML - EGDefault © Customize result formats, styles, and behavior □ SAS Report 0 HTML □ PDF □ RTF □ Text Graph Format: EGDefault EGDefault printer Rtf ActiveX □ Automatically open data or results when generated Reset Options The selection pane enables you to select a category of options to view. More(FI)... v OK 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 S^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 Fj? 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 49 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 + CD 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. 214 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 SalelD has been defined. I_ NOTE: Simple index Product_Group has been defined. NOTE: Simple index Customer_ID has been defined. 215 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. 216 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 • The following code would delete the indexes: proc datasets library=orion nolist; modify sales_history; index delete Customer ID Product ID)/unique; quit; Product Group SalelD; p303d02 quit; 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=//27/-e/rNOLIST; MODIFY SAS-data-set-name, INDEX DELETE index-name, INDEX CREATE index-specification < / options>) QUIT; 218 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. 221 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 Name of Index Variable Name on orion.sales_history(Product_Group); create unique index SalelD on orion.sales_history(Order_ID, Product_ID); quit; • The following code would delete the indexes: proc sql; drop index Customer_IDf Product_Groupf SalelD from orion.sales_history; quit; p303d03 223 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