编辑: 向日葵8AS 2019-07-13
Introduction to SAS? Mike Zdeb (send comments, corrections to: msz03@albany.

edu) #71 (6) PROCEDURES Up to now, SAS procedures have been used without much discussion as to how they work, options available, or why you would use one procedure in lieu of another. There has been a lot of explanation of how to convert raw data into SAS data sets, how to read SAS data sets, the rules for naming variables and data sets, etc. without much reference to using data sets in procedures. All of the discussion of SAS rules and SAS statements will have more grounding if put into the context of what you can do with data once it is in a SAS data set. As mentioned in the introduction, there many parts to SAS and there are procedures that are specific to the various parts of SAS. If you perform a regression analysis using your data, you will have to use a procedure that is part of SAS/STAT. If you want to create presentation quality graphics, you will have to use a procedure that is part of SAS/GRAPH. Many of the main tasks you want to perform with data are accomplished using BASE SAS procedures: rearranging data;

reporting;

counting;

computing descriptive statistics. These tasks are demonstrated using PROC PRINT and PROC REPORT (reporting), PROC FREQ and PROC TABULATE (counting), PROC SORT (rearranging), PROC MEANS, PROC UNIVARIATE, PROC TABULATE, and PROC REPORT (descriptive statistics). The data to be used in discussing these procedures are in a data set named CANCER99. There are five variables in that data set and they are shown below in the output from PROC CONTENTS. This is the default output from PROC CONTENTS, run with no extra options as follows. ...Example 6.1... libname x '

k:\epi514\datasets'

;

title '

CONTENTS OF DATA SET CANCER99'

;

proc contents data=x.cancer99;

run;

Introduction to SAS? Mike Zdeb (send comments, corrections to: [email protected]) #72 The default output of PROC CONTENTS gives you details about a data set. In addition to the names and attributes of variables, it also tells you the number of observations and variables in the data set and the date that the data set was created. You can change the order of the list of variables by uisng a VARNUM option. If you have a mix of variables beginning with both small and capital letters, PROC CONTENTS will list all variables starting with capital letters first, followed by those starting with small letters. ...Example 6.2... data test;

? a_variable = 10;

c_variable = 20;

B_variable = 30;

Z_variable = '

MIKE'

;

run;

title '

MIXED CASE STARTING LETTERS'

;

proc contents data=test;

? run;

title '

MIXED CASE STARTING LETTERS-IGNORECASE PROC OPTION'

;

proc contents data=test order=ignorecase;

? run;

options validvarname=upcase;

? title '

MIXED CASE STARTING LETTERS-VALIDVARNAME OPTION'

;

proc contents data=test;

? run;

options validvarname=v7;

? A small data set is created that contains variables that start with both small and capital letters ?. PROC CONTENTS run without any options produces a variable list that has the capital letters first, followed by the small letters (upper box on the above right) ?. Adding an IGNORECASE option in PROC CONTENTS places the variables in alphabetic order (middle box on the above right) ?. Setting the VALIDVARNAME system option to UPCASE ? produces a list of variables in alphabetic order (lower box on the above right) even when PROC CONTENTS is run without an IGNORECASE option ?. However, all the variables are displayed in uppercase. To return to the default display of variables, the VALIDVARNAME system option is reset to V7 ?. The VARNUM option changes the order of the variable list to correspond with the variable position in the data set, while the SHORT option limits the PROC CONTENTS output to a list of variable names that are still, by default, in alphabetic order following all the rules described in example 6.2. ...Example 6.3... libname x k:\epi514\datasets ;

下载(注:源文件不在本站服务器,都将跳转到源网站下载)
备用下载
发帖评论
相关话题
发布一个新话题