统计211

标题: SAS 9.2帮助很好很强大 [打印本页]

作者: 晚风    时间: 2011-7-27 19:58
标题: SAS 9.2帮助很好很强大

一直觉得SAS的帮助做的很棒,想不到9.2考虑得更加完善,居然提供了一个Learning to Use SAS 这个帮助,很完善的例子,把SAS的每个模块都讲了,非常多,并且有详细的例子,例子看起来也特别简单易懂,如下图:

[attach]865[/attach]
大家把例子全部过一遍,基本上就把SAS得功能全部走一遍了,很好,如下一个调用外部DLL函数的例子:

/****************************************************************/
/*          S A S   S A M P L E   L I B R A R Y                 */
/*                                                              */
/*    NAME: EXDLL1                                              */
/*   TITLE: External DLL Example 1 : Calling Functions within  +*/
/*          External DLLs from the DATA Step                    */
/* PRODUCT: SAS                                                 */
/*  SYSTEM: Windows                                             */
/*    KEYS: MODULE                                              */
/*   PROCS:                                                     */
/*    DATA:                                                     */
/*     REF:                                                     */
/*    MISC:                                                     */
/*    DESC: Demonstrates how to use the SAS System's MODULE     */
/*          functions/call routines to utilize both API and     */
/*          user-written functions located within Dynamic Link  */
/*          Libraries (DLLs).  In this example, the Windows API */
/*          function "MessageBoxA" is being called to display   */
/*          a dialog box with message text and 2 push buttons.  */
/****************************************************************/

/* Assign the MODULE routine specific fileref "SASCBTBL".       */
/* This fileref points to an attribute table definition table   */
/* used to describe the parameters and responses for each       */
/* function, the name of the DLL they are located in, and their */
/* architecture.  There must be an entry in this table for each */
/* function called by the MODULE routine.  In this example we   */
/* are creating a temporary work file utilizing the CATALOG     */
/* access method (new to 6.11).                                 */

FILENAME SASCBTBL CATALOG "work.temp.attrfile.source";

/* This DATA step dynamically creates an attribute table to     */
/* define the MessageBoxA API function used in the example      */
/* code below.  NOTE: Using an incorrect attribute definition   */
/* could abnormally terminate your SAS session or, even worse,  */
/* halt your operating system.  CAUTION IS ADVISED!!            */

DATA _NULL_;
    FILE SASCBTBL;

    PUT "ROUTINE MessageBoxA";
    PUT "    MINARG=4";
    PUT "    MAXARG=4";
    PUT "    STACKPOP=CALLED";
    PUT "    MODULE=USER32";
    PUT "    RETURNS=LONG;";
    PUT "  ARG 1 NUM  BYVALUE FORMAT=PIB4.;";
    PUT "  ARG 2 CHAR         FORMAT=$CSTR200.;";
    PUT "  ARG 3 CHAR         FORMAT=$CSTR200.;";
    PUT "  ARG 4 NUM  BYVALUE FORMAT=PIB4.;";
RUN;

/*--------------------------------------------------------------*/
/* The following SAS macro variables are defined to simplify    */
/* the specification of the parameters to the MessageBoxA       */
/* function.                                                    */
/*--------------------------------------------------------------*/
/*   Buttons or Button Groups                                   */
%LET MBOK     = 0;     /* [OK] - Default                        */
%LET MBOKCAN  = 1;     /* [OK]  [Cancel]                        */
%LET MBABREIG = 2;     /* [Abort]  [Retry]  [Ignore]            */
%LET MBYENOCA = 3;     /* [Yes]  [No]  [Cancel]                 */
%LET MBYESNO  = 4;     /* [Yes]  [No]                           */
%LET MBRETCAN = 5;     /* [Retry]  [Cancel]                     */
/*   Icons                                                      */
%LET MBNOICON = 0;     /* No icon - Default                     */
%LET MBISTOP = 16;     /* A 'STOP' icon                         */
%LET MBIQUEST = 32;    /* A question mark icon                  */
%LET MBIEXCLA = 48;    /* An exclamation mark icon              */
%LET MBIINFOR = 64;    /* An information 'i' icon               */
/*   Default Button                                             */
%LET MBDEFB1  = 0;     /* 1st button is the default - Default   */
%LET MBDEFB2  = 256;   /* 2nd button is the default             */
%LET MBDEFB3  = 512;   /* 3rd button is the default             */
/*   Response Codes  (NOTE: These indicate the button selected) */
%LET MBIDOK   = 1;     /* [OK] was selected                     */
%LET MBIDCAN  = 2;     /* [Cancel] was selected                 */
%LET MBIDABO  = 3;     /* [Abort] was selected                  */
%LET MBIDRET  = 4;     /* [Retry] was selected                  */
%LET MBIDIGN  = 5;     /* [Ignore] was selected                 */
%LET MBIDYES  = 6;     /* [Yes] was selected                    */
%LET MBIDNO   = 7;     /* [No] was selected                     */
%LET MBIDERR  = 0;     /* An API error occurred (check params)  */
/*--------------------------------------------------------------*/
/* MessageBoxA PARAMETERS AND RETURN CODES:                     */
/* Usage:                                                       */
/*   Response = MessageBoxA(0, Message, Caption, Style)         */
/*                                                              */
/* Response - The value returned from the function indicating   */
/*            what action the user took (see Response Codes     */
/*            above).                                           */
/* Message  - The text to appear in the body of the dialog.     */
/* Caption  - Text to be used in for the dialog's caption.      */
/* Style    - A number indicating features required in the      */
/*            dialog box (icons and buttons).  The number is    */
/*            derived by adding one value from each of the      */
/*            first 3 sections above (Buttons or Button Groups, */
/*            Icons and Default Button) together.               */
/*--------------------------------------------------------------*/

/* Use the MODULE interface to call the MessageBoxA function.   */

DATA _NULL_;
     response = MODULEN("MessageBoxA", 0,
   "This is the text that appears as the dialog message.",
   "THIS IS THE CAPTION TEXT",
   &MBOKCAN + &MBIINFOR + &MBDEFB1);

     SELECT (response);
  WHEN (&MBIDOK)
      PUT "The [OK] button was selected.";
  WHEN (&MBIDCAN)
      PUT "The [CANCEL] button was selected.";
  WHEN (&MBIDERR)
      PUT "An ERROR condition occurred." /
   "Check the MessageBoxA parameters.";
  OTHERWISE
      PUT "An unexpected response code of" response
   " was returned.";
     END;
RUN;








欢迎光临 统计211 (http://tj211.com/) Powered by Discuz! X3.2