Chapter 20: Procedures under Windows


SAS Procedures under Windows

Base SAS procedures enable you to perform statistical computations , create reports , and manage your data. Most of the Base SAS procedures are described in Base SAS Procedures Guide . The procedures described here have syntax or behavior that is specific to Windows.

CATALOG Procedure

Manages entries in SAS catalogs

Windows specifics: FILE= option in the CONTENTS statement

See: CATALOG Procedure in Base SAS Procedures Guide

Syntax

PROC CATALOG CATALOG=< libref. > catalog <ENTRYTYPE= etype > <KILL>;

  • CONTENTS <OUT= SAS-data-set > <FILE= fileref ;>

Note: This is a simplified version of the CATALOG procedure syntax. For the complete syntax and its explanation, see the CATALOG procedure in Base SAS Procedures Guide .

fileref

  • names a file specification that is specific to the Windows operating environment.

Details

The CATALOG procedure manages entries in SAS catalogs.

The FILE= option in the CONTENTS statement of the CATALOG procedure accepts a file specification that is specific to the Windows operating environment. If an unquoted file specification is given in the FILE= option, but no FILENAME statement, SET system option, or Windows environment variable is used to define the file specification, the file is named file-specification .LST and is stored in the working directory. For example, if MYFILE is not a fileref defined by the FILENAME statement, the SET system option, or a Windows environment variable, and you submit the following statements, the file MYFILE.LST, containing the list of contents for Sasuser.Profile, is created in your working directory:

 proc catalog catalog=sasuser.profile;     contents file=myfile;  run; 

CIMPORT Procedure

Restores a transport file created by the CPORT procedure

Windows specifics: Name and location of transport file

See: CIMPORT Procedure in Base SAS Procedures Guide

Syntax

PROC CIMPORT destination = libref < libref. > member-name < option(s) >;

Note: This is a simplified version of the CIMPORT procedure syntax. For the complete syntax and its explanation, see the CIMPORT procedure in Base SAS Procedures Guide .

destination

  • identifies the file(s) in the transport file as a single SAS data set, single SAS catalog, or multiple members of a SAS data library.

libref <libref.>member-name

  • specifies the name of the SAS data set, catalog, or library to be created from the transport file.

Details

The CIMPORT procedure imports a transport file that was created ( exported ) by the CPORT procedure.

Coupled with the CPORT procedure, the CIMPORT procedure enables you to move catalogs and data sets from one operating environment to another.

Note: PROC CIMPORT processes a file generated by PROC CPORT, not a transport file generated by the XPORT engine.

When you use the CIMPORT procedure under Windows, remember the following:

  • The value of the INFILE= option can be a fileref defined in a FILENAME statement, a quoted Windows pathname, or an environment variable.

  • If you omit the INFILE= option and have not defined the reserved fileref SASCAT, SAS tries to read from a file named SASCAT.DAT in your working directory. If no file by that name exists, the following error message is issued and the procedure terminates, assuming that C:\SAS has been defined as the working directory:

     ERROR: Physical file does not exist, C:\SAS\SASCAT.DAT 
  • If you have not transferred the file created by PROC CPORT in binary format, PROC CIMPORT cannot read the file, and you receive the following message:

     ERROR: Given transport file is bad. 

CONTENTS Procedure

Prints descriptions of the contents of one or more SAS data library files

Windows specifics: Engine/Host Dependent Information output

See: CONTENTS Procedure in Base SAS Procedures Guide

Syntax

PROC CONTENTS < option(s) >;

option(s)

  • For an explanation of the available options, see the CONTENTS procedure in Base SAS Procedures Guide .

Details

The CONTENTS procedure shows the contents of a SAS data set and prints the directory of the SAS data library.

While most of the printed output generated by the CONTENTS procedure is the same across all operating environments, the Engine/Host Dependent Information output depends on both the operating environment and the engine. The following example output shows the Engine/Host Dependent Information that is generated for the V9 engine from these statements:

 DATA SCHOOL;     INPUT NAME $ Y GRADE CLASS $ ID;     DATALINES;   PHIL 1 85 MATH 234107589   ROBERTO 1 90 ENGLISH 190873452   CAROL 2 70 MATH 257902348   THOMAS 2 71 ENGLISH 234567823   JUANITA 3 98 FRENCH 876345290   CEDRIC 3 75 HISTORY 231987222   MARIA 4 89 PE 87654321   ;  PROC CONTENTS DATA=SCHOOL OUT=SCHOUT(DROP=CRDATE MODATE);     TITLE 'SCHOOL DATASET';     RUN; 
Output 20.1: Engine/Host Dependent Information from PROC CONTENTS Using the V9 Engine
start example
 SCHOOL DATASET                 07:52 Monday, march 17, 2003     1                                          The CONTENTS Procedure               Data Set Name        WORK.SCHOOL                     Observations          7               Member Type          DATA                            Variables             5               Engine               V9                              Indexes               0               Created              Monday, March 17, 2003 00:39:17 Observation Length    40               Last Modified        Monday, March 17, 2003 00:39:17 Deleted Observations  0               Protection                                           Compressed            NO               Data Set Type                                        Sorted                NO               Label               Data Representation  WINDOWS_32               Encoding             wlatin1 Western (Windows)                                    Engine/Host Dependent Information  Data Set Page Size         4096  Number of Data Set Pages   1  First Data Page            1  Max Obs per Page           101  Obs in First Data Page     7  Number of Data Set Repairs 0  File Name                  C:\DOCUME~1\sasusr1\LOCALS~1\Temp\SAS Temporary Files\_TD1904\school.sas7bdat  Release Created            9.0101B0  Host Created               XP_PRO                               Alphabetic List of Variables and Attributes                                      #    Variable    Type    Len                                      4    CLASS       Char      8                                      3    GRADE       Num       8                                      5    ID          Num       8                                      1    NAME        Char      8                                      2    Y           Num       8 
end example
 

The engine name (V9) is listed in the header information. The Engine/Host Dependent Information describes attributes of the data set, such as the data set page size and the maximum number of observations per page. For more information about how to interpret the data set size information, see 'Calculating Data Set Size' on page 208.

See Also

CONVERT Procedure

Converts BMDP, OSIRIS system files and SPSS export files to SAS data sets

Windows specifics: All

Syntax

PROC CONVERT product-specification < option(s) >

product-specification

  • is required and can be one of the following:

  • BMDP= fileref <(CODE= code CONTENT= content-type )>

    • converts into a SAS data set the first member a BMDP save file created under DOS. Here is an example:

       filename save 'c:\myidr\bmdp.dat';  proc convert bmdp=save;  run; 

      If you have more than one save file in the BMDP file referenced by the fileref argument, you can use two options in parentheses after fileref . The CODE= option lets you specify the code of the save file you want, and the CONTENT= option lets you give the content of the save file. For example, if a file with CODE=JUDGES has a content of DATA, you can use the following statement:

       filename save 'c:\mydir\bmdpl.dat';  proc convert bmdp=save(code=judges                         content=data);  run; 
  • OSIRIS= fileref

    • specifies a fileref for the OSIRIS file to be converted into a SAS data set. If you use this product specification, you must also use the DICT= option, which specifies the OSIRIS dictionary to use.

  • SPSS= fileref

    • specifies a fileref for the SPSS export file to be converted into a SAS data set. The SPSS export file must be created by using the SPSS EXPORT command from any operating environment.

option-list

  • DICT= fileref

    • specifies a fileref of the dictionary file for the OSIRIS file. The DICT= option is valid only when used with the OSIRIS product specification.

  • FIRSTOBS= n

    • gives the number of the observation where the conversion is to begin. This enables you to skip over observations at the beginning of the OSIRIS or SPSS/PC system file.

  • OBS= n

    • specifies the number of the last observation to convert. This option enables you to exclude observations at the end of the file.

  • OUT= SAS-data-set

    • names the SAS data set created to hold the converted data. If the OUT= option is omitted, SAS still creates a Work data set and automatically names it DATA n , just as if you omitted a data set name in a DATA statement. If it is the first such data set in a job or session, SAS names it DATA1, the second is DATA2, and so on. If the OUT= option is omitted or if you do not specify a two-level name (including a libref) in the OUT= option, the converted data set is stored in your Work data library and by default it is not permanent.

Details

The CONVERT procedure converts a BMDP or OSIRIS system file or an SPSS export file to a SAS data set. It produces one output data set, but no printed output. The new data set contains the same information as the input system file; exceptions are noted in 'Output Data Sets' on page 428. The BMDP, OSIRIS and SPSS engines provide more extensive capabilities.

Because the BMDP, OSIRIS and SPSS products are maintained by other companies or organizations, changes may be made that make the system files incompatible with the current version of PROC CONVERT. SAS upgrades PROC CONVERT only to support changes that are made to these products when a new version of SAS is available.

Missing Values If a numeric variable in the input data set has either no value or a system missing value, PROC CONVERT assigns it a missing value.

Output Data Sets This section describes the attributes of the output SAS data set for each product-specification value.

CAUTION:

  • Be sure that the translated names are unique. Variable names can sometimes be translated by SAS. To ensure the procedure works correctly, be sure your variables are named in such a way that translation results in unique names.

BMDP output Variable names from the BMDP save file are used in the SAS data set, but nontrailing blanks and all special characters are converted to underscores in the SAS variable names. The subscript in BMDP variable names, such as x(1), becomes part of the SAS variable name, with the parentheses omitted: X1. Alphabetic BMDP variables become SAS character variables of corresponding length. Category records from BMDP are not accepted.

OSIRIS Output For single-response variables, the V1-V9999 name becomes the SAS variable name. For multiple-response variables, the suffix R n is added to the variable name, where n is the response. For example, V25R1 is the first response of the multiple-response variable V25. If the variable after V1000 has 100 or more responses, responses above 99 are eliminated. Numeric variables that OSIRIS stores in character, fixed-point binary, or floating-point binary mode become SAS numeric variables. Alphabetic variables become SAS character variables; any alphabetic variable of length greater than 200 is truncated to 200. The OSIRIS variable description becomes a SAS variable label, and OSIRIS print formats become SAS formats.

SPSS Output SPSS variable names and variable labels become variable names and labels without change. SPSS alphabetic variables become SAS character variables. SPSS blank values are converted to SAS missing values. SPSS print formats become SAS formats, and the SPSS default precision of no decimal places becomes part of the variables' formats. SPSS value labels are not copied. DOCUMENT data are copied so that PROC CONTENTS can display them.

Comparison

The CONVERT procedure is closely related to the BMDP, OSIRIS and SPSS interface library engines. (In fact, the CONVERT procedure uses these engines.) For example, the following two sections of code provide identical results:

  •  filename myfile 'myspss.por';  proc convert spss=myfile out=temp;   run; 
  •  libname myfile spss 'myspss.por';  data temp;      set myfile._first_;   run; 

However, the BMDP, OSIRIS and SPSS engines have more extensive capabilities than PROC CONVERT.

See Also
  • 'Reading BMDP, OSIRIS and SPSS Files' on page 140

CPORT Procedure

Writes SAS data sets and catalogs into a special format in a transport file

Windows specifics: Name and location of transport file

See: CPORT Procedure in Base SAS Procedures Guide

Syntax

PROC CPORT source-type = libref < libref. > member-name < option(s) >;

Note: This is a simplified version of the CPORT procedure syntax. For the complete syntax and its explanation, see the CPORT procedure in Base SAS Procedures Guide .

libref

  • specifies the name and location of the file to be transported.

Details

The CPORT procedure writes SAS data sets, SAS catalogs, or SAS data libraries to sequential file formats (transport files). Use PROC CPORT with the CIMPORT procedure to move files from one environment to another.

The value of the FILE= option can be a fileref defined in a FILENAME statement, a quoted Windows pathname, or an environment variable.

If you do not use the FILE= option and have not defined the reserved fileref SASCAT, a file named SASCAT.DAT is created in your working directory.

See Also
  • 'CIMPORT Procedure' on page 424

  • 'Transferring SAS Files between Operating Environments' on page 143

DATASETS Procedure

Lists, copies, renames, and deletes SAS files and also manages indexes for and appends SAS data sets in a SAS data library

Windows specifics: Directory information; CONTENTS statement output

See: DATASETS Procedure in Base SAS Procedures Guide

Syntax

PROC DATASETS < options(s) >;

  • CONTENTS < options(s) >;

option(s)

  • This is a simplified version of the DATASETS procedure syntax. For the complete syntax, see the DATASETS procedure in Base SAS Procedures Guide .

Details

The DATASETS procedure is a utility procedure that manages your SAS files.

The SAS data library information that is displayed in the SAS log by the DATASETS procedure depends on the operating environment and the engine. The following example SAS log shows the information (for the V9 engine) that the DATASETS procedure generates under Windows.

Output 20.2: SAS Data Library Information from PROC DATASETS
start example
 PROC DATASETS library=work;                             Directory         Libref         WORK         Engine         V9         Physical Name  C:\DOCUME~1\sasusr\LOCALS~1\Temp\SAS Temporary Files\_TD2663         File Name      C:\DOCUME~1\sasusr\LOCALS~1\Temp\SAS Temporary Files\_TD2663                     Member     File         #  Name     Type       Size  Last Modified         1  GSEG     CATALOG   54272   17MAR2003:13:20:23         2  HAT      DATA      46080   17MAR2003:13:20:20         3  SASGOPT  CATALOG    5120   17MAR2003:13:20:21 
end example
 

The output shows you the libref, engine, and physical name that are associated with the library, as well as the names and other properties of the SAS files that are contained in the library.

The CONTENTS statement in the DATASETS procedure generates the same Engine/ Host Dependent Information as the CONTENTS procedure.

See Also

OPTIONS Procedure

Lists the current values of all SAS system options

Windows specifics: Host options

See: OPTIONS Procedure in Base SAS Procedures Guide

Syntax

PROC OPTIONS < options(s) >;

option(s)

  • This is a simplified version of the OPTIONS procedure syntax. For the complete syntax and its explanation, see the OPTIONS procedure in Base SAS Procedures Guide .

Details

The OPTIONS procedure lists the current settings of the SAS system options.

The options displayed by the OPTIONS procedure that are not operating environment specific (session and configuration) are the same for every operating environment, although the default values may differ slightly. However, the environment-specific options displayed by this procedure are different for each operating environment. The following display shows some sample operating environment options for the Windows environment, as generated by this code:

 proc options host;  run; 
Output 20.3: Windows Operating Environment Options Displayed by PROC OPTIONS
start example
 Host Options:   ACCESSIBILITY=STANDARD                     Enable Extended Accessibility   ALTLOG=           Specifies the destination for a copy of the SAS log   ALTPRINT=         Specifies the destination for a copy of the SAS procedure output file   AUTHPROVICERDOMAIN=                     Authentication providers associated with domain suffixes   AUTHSERVER=       Specify the authentication server or domain.   AUTOEXEC=         Specifies the autoexec file to be used   AWSCONTROL=(SYSTEMMENU MINMAX TITLE)                     Used to customize the appearance for the SAS AWS.  Valid parameters are:                     TITLE/NOTITLE SYSTEMMENU/NOSYSTEMMENU MINMAX/NOMINMAX   AWSDEF=(  0   0  79 79)                     Specify the initial size and position of the SAS AWS. This should be                     specified as follows: 0 0 100 100   AWSMENU           Show the main window's (AWS) menu.   AWSMENUMERGE      Add host specific menu items to the main window's (AWS) menu.  ...   NOTE:  PROCEDURE OPTIONS used:( Total process time)          real time           0.01 seconds          cpu time            0.01 seconds 
end example
 

The option values listed in is display are examples only. The output of PROC OPTIONS depends on many things. Some option values depend on what method you use to run SAS. For example, the default line size under the SAS windowing environment is 75 lines on a VGA display, while it is 132 lines in batch mode. Also, the way you have set up your process affects the default values of system options. For example, the default value of the SASAUTOS= option depends on where you store your autocall macros.

Using PROC OPTIONS, you can check the values of all system options. If you want more information about a particular operating environment option, refer to 'SAS System Options under Windows' on page 467 or Using SAS Software in Your Operating Environment in the SAS Help and Documentation.

See Also
  • 'SAS System Options under Windows' on page 467

PMENU Procedure

Defines pull-down menu facilities for windows created with SAS software

Windows specifics: ACCELERATE= option accepted for several key combinations

See: PMENU Procedure in Base SAS Procedures Guide

Syntax

PROC PMENU <CATALOG=< libref. > catalog > <DESC ' entry-description '>;

  • ITEM command < option(s) >;

  • ITEM ' menu-item ' < option(s) >;

    • ACCELERATE= name-of-key ;

This is a simplified version of the PMENU procedure syntax. For the complete syntax, see the PMENU procedure in Base SAS Procedures Guide .

ACCELERATE= name-of-key

  • defines a key sequence that can be used instead of selecting an item. When you press the key sequence, it has the same effect as selecting the item from the menu bar or pull-down menu.

    Under Windows, the ACCELERATE= option in the ITEM statement is accepted only for the following key combinations:

    • Ctrl + A (Select All)

    • Ctrl + C (Copy)

    • Ctrl + F (Find)

    • Ctrl + N (New)

    • Ctrl + O (Include)

    • Ctrl + P (Print)

    • Ctrl + S (File)

    • Ctrl +X (Cut).

    • Ctrl +V (Paste)

    • Ctrl + Z (Undo)

    • Del (Clear)

Details

The PMENU procedure defines pull-down menus that can be used in DATA step windows, macro windows, SAS/AF and SAS/FSP windows, or in any SAS application that enables you to specify customized menus .

If you want your program to be portable between Windows and OS/2, you can use the following alternate key combinations:

  • Ctrl+Insert

  • Shift+Insert

  • Alt+Backspace

  • Shift+Delete.

If you use these alternate key combinations in your SAS program, the Edit pull-down menu shows the standard key combination; however, you can use either the standard or alternate key combination to activate the menu item.

PRINTTO Procedure

Defines destinations for SAS procedure output and the SAS log

Windows specifics: Valid values for file-specification ; UNIT= option

See: PRINTTO Procedure in Base SAS Procedures Guide

Syntax

PROC PRINTTO < option(s) >;

Note: This is a simplified version of the PRINTTO procedure syntax. For the complete syntax and its explanation, see the PRINTTO procedure in Base SAS Procedures Guide .

option(s)

  • LOG= file-specification

  • PRINT= file-specification

    • can be

      • a fileref defined in a FILENAME statement or function. To send SAS output or log directly to the printer, use a FILENAME statement or function with the PRINTER device-type keyword.

      • a quoted Windows pathname

      • an alphanumeric text string. The destination filename is file-specification .LOG or file-specification .LST and it is stored in the current directory.

      • a SAS or Windows environment variable

  • UNIT= nn

    • sends your SAS procedure output to the file FT nn F001.LST, where nn represents the UNIT= value, which can range from 1 to 99. The file is located in the SAS working directory.

Details

The PRINTTO procedure defines destinations for SAS procedure output and for the SAS log.

Examples
Example 1: Redirecting SAS Log Output

The following statements redirect any SAS log entries that are generated after the RUN statement to an output file with a fileref of TEST, which is associated with the LPT1: device:

 filename test printer 'lpt1:';  proc printto log=test;  run; 

When these statements are issued, a dialog box is opened that informs you PROC PRINTTO is running. All SAS log entries are redirected to the TEST output file as specified; however, they are not printed on the LPT1: device until the output file is closed, either by redirecting the SAS log entries back to the default destination or to another file.

The following statements send any SAS log entries that are generated after the RUN statement to the external file associated with the fileref MYFILE:

 filename myfile 'c:\mydir\mylog.log';  proc printto log=myfile;  run; 
Example 2: Redirecting SAS Procedure Output

The following statements send any SAS procedure output to a file named MYPRINT.LST in your working directory (assuming MYPRINT is not a previously defined fileref or environment variable):

 proc printto print=myprint;  run; 

The following statements send any SAS procedure output to the printer port, which is usually defined by the system as LPT1:

 proc printto print='lpt1:';  run; 
Example 3: Restoring the Output Destinations to the Default

The following statements (including a PROC PRINTTO statement with no options) redirect the SAS log and procedure output to the original default destinations:

 proc printto;  run; 

SORT Procedure

Sorts observations in a SAS data set by one or more variables, then stores the resulting sorted observations in a new SAS data set or replaces the original data set

Windows specifics: Sort utilities available; SORTSIZE= and TAGSORT statement options

See: SORT Procedure in Base SAS Procedures Guide

Syntax

PROC SORT < option(s) >< collating-sequence-option >;

Note: This is a simplified version of the SORT procedure syntax. For the complete syntax and its explanation, see the SORT procedure in Base SAS Procedures Guide

SORTSIZE= memory-specification

  • specifies the maximum amount of memory available to the SORT procedure. For further explanation of the SORTSIZE= option, see the following Details section.

TAGSORT

  • stores only the BY variables and the observation number in temporary files. When you specify TAGSORT, the sort is a single-threaded sort. Do not specify TAGSORT if you want SAS to use multiple threads to sort. For details about TAGSORT option, see the following Details section.

Details

The SORT procedure sorts observations in a SAS data set by one or more character or numeric variables, either replacing the original data set or creating a new, sorted data set. By default under Windows, the SORT procedure uses the ASCII collating sequence.

The SORT procedure uses the sort utility specified by the SORTPGM system option. Sorting can be done by SAS, your database, or the Windows SyncSort utility. You can use all the options available to the SAS sort utility, such as the SORTSEQ and NODUPKEY options. For a complete list of all options available, see the list of sort options in the See Also section.

SORTSIZE= Option

Under Windows, you can use the SORTSIZE= option in the PROC SORT statement to limit the amount of memory that is available to the SORT procedure. This option might reduce the amount of swapping SAS must do to sort the data set. If PROC SORT needs more memory than you specify, it creates a temporary utility file to store the data in. The SORT procedure's algorithm can swap data more efficiently than Windows can.

The syntax of the SORTSIZE= option is as follows:

SORTSIZE= memory-specification

where memory-specification can be one of the following:

n

specifies the amount of memory in bytes.

n K

specifies the amount of memory in 1-kilobyte multiples .

n M

specifies the amount of memory in 1-megabyte multiples.

The default SAS configuration file sets this option to 64MB using the SORTSIZE= system option.

You can override the default value of the SORTSIZE= system option by specifying a different SORTSIZE= value in the PROC SORT statement, or by submitting an OPTIONS statement that sets the SORTSIZE= system option to a new value.

The SORTSIZE= option is also discussed in 'Improving Performance of the SORT Procedure' on page 206.

TAGSORT Option

The TAGSORT option in the PROC SORT statement is useful in sorts when there may not be enough disk space to sort a large SAS data set. When you specify TAGSORT, the sort is a single-threaded sort. Do not specify TAGSORT if you want the SAS to use multiple threads to sort.

When you specify the TAGSORT option, only sort keys (that is, the variables specified in the BY statement) and the observation number for each observation are stored in the temporary files. The sort keys, together with the observation number, are referred to as tags . At the completion of the sorting process, the tags are used to retrieve the records from the input data set in sorted order. Thus, in cases where the total number of bytes of the sort keys is small compared with the length of the record, temporary disk use is reduced considerably. You should have enough disk space to hold another copy of the data (the output data set) or two copies of the tags, whichever is greater. Note that while using the TAGSORT option may reduce temporary disk use, the processing time may be much higher. However, on PCs with limited available disk space, the TAGSORT option may allow sorts to be performed in situations where they would otherwise not be possible.

Creating Your Own Collating Sequences

If you want to provide your own collating sequences or change a collating sequence that has been provided for you, use the TRANTAB procedure to create or modify translate tables. For more information about the TRANTAB procedure, see SAS National Language Support (NLS): User 's Guide . When you create your own translate tables, they are stored in your Sasuser.Profile catalog and they override any translate tables by the same name that are stored in the HOST catalog.

Note: System managers can modify the HOST catalog by copying newly created tables from the Sasuser.Profile catalog to the HOST catalog. Then all users can access the new or modified translate table.

If you want to see the names of the collating sequences stored in the HOST catalog (using the SAS Explorer), submit the following statement:

 dm 'catalog sashelp.host' catalog; 

Alternatively, you can select the View pull-down menu, then select the Libraries item, then double-click on the Sashelp library, and then double-click on the HOST catalog. In batch mode, you can use the following statements to generate a list of the contents of the HOST catalog:

 proc catalog catalog=sashelp.host;     contents;  run; 

Entries of type TRANTAB are the collating sequences.

If you want to see the contents of a particular translate table, use the following statements:

 proc trantab table=  table-name  ;     list;  run; 

The contents of the collating sequence are displayed in the SAS log.

Using Syncsort for Windows

Introduction to Using SyncSort with SAS If you have SyncSort installed at your site, you can use Syncsort as an alternative sorting algorithm to the database sort or the SAS sort. SAS determines which sort to use by the values that are set for the SORTPGM, SORTCUT, and SORTCUTP system options.

The SyncSort installation process adds the SyncSort directory to the Windows PATH statement. As long as the SyncSort directory is included in the Windows PATH statement, SAS is able to launch SyncSort. SyncSort is developed by Syncsort, Inc.

Setting SyncSort as the Sort Algorithm To always sort using the SyncSort sort routine, the value of the SORTPGM system option must be HOST. To set this option, submit the following OPTIONS statement:

 options sortpgm=host; 

Note: The SORTPGM option can also be set from the SAS System Options window, in the SAS configuration file, or during SAS invocation. This example shows how to specify the SORTPGM system option at invocation or in the SAS configuration file:

 -sortpgm host 

Sorting Based on Size or Observations The sort routine that SAS uses can be based on either the number of observations in a data set or on the size of the data set. When the SORTPGM option is set to BEST, SAS uses the first available and pertinent sorting algorithm based on this order of precedence:

  • database sort utility

  • host sort utility

  • SAS sort utility

If sorting is not to be done by the database, SAS looks at the values for the SORTCUT and SORTCUTP options to determine which sort to use.

The SORTCUT option specifies the number of observations above which SyncSort is used instead of the SAS sort. The SORTCUTP option specifies the number of bytes in the data set above which SyncSort is used.

If SORTCUT and SORTCUTP are set to zero, SAS uses the SAS sort routine. If you specify both options and either condition is met, SAS uses SyncSort.

When the following OPTIONS statement is in effect, the SyncSort routine is used when the number of observations is 501 or greater:

 options sortpgm=best sortcut=500; 

Here, the SyncSort routine is used when the size of the data set is greater than 40M:

 options sortpgm=best sortcutp=40M; 

For more information about these sort options, see 'SORTPGM System Option' on page 555, 'SORTCUT System Option' on page 552 and 'SORTCUTP System Option' on page 553

Changing the Location of SyncSort Temporary Files By default, SyncSort uses the location that is specified in the -WORK option for temporary files. To change the location of SyncSort temporary files, specify a new location by using the SORTDEV option. Here is an example:

 options sortdev="c:\temp\sortsync"; 

For more information about the SORTDEV options, see 'SORTDEV System Option' on page 554.

Passing Options to SyncSort Use the SORTANOM option to specify the options that you want to use for SyncSort:

Table 20.1: SORTANOM Options for SyncSort

Task

SORTANOM Option

Run in multi-call mode instead of single-call mode

SORTANOM=b

Print statistics in the SAS log about the sorting process

SORTANOM=t

Print in the SAS log the commands that have been passed to Syncsort

SORTANOM=v

Multiple options can be specified by concatenating the options:

 options sortdev=btv; 

For more information about the SORTANOM option, see 'SORTANOM System Option' on page 551.

Passing Parameters to SyncSort Use the SORTPARM option to pass Syncsort options to SyncSort. Enclose the options in quotations marks as in this OPTIONS statement:

 options sortparm="  SyncSort-options  "; 

For information about the SORTPARM option, see 'SORTPARM System Option' on page 555. See the SyncSort documentation for a description of the SyncSort options.

Specifying the SORTSEQ= Option with a Host Sort Utility

The SORTSEQ= option enables you to specify the collating sequence for your sort. For a list of valid values, see the SORT procedure in Base SAS Procedures Guide .

CAUTION:

  • If you are using a host sort utility to sort your data, then specifying the SORTSEQ= option might corrupt the character BY variables if the sort sequence translation table and its inverse are not one-to-one mappings. The translation table must map each character to a unique weight, and the inverse table must map each weight to a unique character variable.

If your translation tables are not one-to-one mappings, then you can use one of the following methods to perform your sort:

  • create a translation table that maps one-to-one. When you create a translation table that maps one-to-one, you can easily create a corresponding inverse table by using the TRANTAB procedure. If your table is not mapped one-to-one, then you will receive the following note in the SAS log when you try to create an inverse table:

     NOTE: This table cannot be mapped one to one. 

    For more information, see the TRANTAB procedure in SAS National Language Support (NLS): User's Guide .

  • use the SAS sort. You can specify the SAS sort by using the SORTPGM system option. For more information, see 'SORTPGM System Option' on page 555.

  • specify the collation order options of your host sort utility. See the documentation for your host sort utility for more information.

  • create a view with a dummy BY variable. For an example, see 'Example: Creating a View with a Dummy BY Variable' on page 439.

Note: After using one of these methods, you might need to perform subsequent BY processing using either the NOTSORTED option or the NOBYSORTED system option. For more information about the NOTSORTED option, see the BY statement in SAS Language Reference: Dictionary . For more information about the NOBYSORTED system option, see the BYSORTED system option in SAS Language Reference: Dictionary .

Example: Creating a View with a Dummy BY Variable The following code is an example of creating a view using a dummy BY variable:

 options no date nostimer ls-78 ps-60;  options sortpgm=host msglevel=i;  data one;     input name $ age;     datalines;     anne 35     ALBERT 10     JUAN 90     janet 5     bridget 23     BRIAN 45     ;  run;  data oneview / view=oneview;     set one;     name1=upcase(name);  run;  proc sort data=oneview out=final(drop=name1);     by name1;  run;  proc print data=final;  run; 

The output is the following:

Output 20.4: Creating a View with a Dummy BY Variable
start example
 The SAS System  Obs        name       age   1         ALBERT      10   2         anne        35   3         BRIAN       45   4         bridget     23   5         janet        5   6         JUAN        90 
end example
 
See Also
  • TRANTAB Procedure' in SAS National Language Support (NLS): User's Guide

  • 'SORTANOM System Option' on page 551

  • 'SORTCUT System Option' on page 552

  • 'SORTCUTP System Option' on page 553

  • 'SORTDEV System Option' on page 554

  • 'SORTPARM System Option' on page 555

  • 'SORTPGM System Option' on page 555

  • 'SORTSIZE System Option' on page 556

  • 'Improving Performance of the SORT Procedure' on page 206




SAS 9.1 Companion for Windows
SAS 9.1 Companion for Windows (2 Volumes)
ISBN: 1590472004
EAN: 2147483647
Year: 2004
Pages: 187

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net