编辑: 向日葵8AS 2019-07-13

title '

CONTENTS OF DATA SET CANCER99 - VARNUM PROC OPTION'

;

proc contents data=x.cancer99 varnum;

run;

title '

CONTENTS OF DATA SET CANCER99 - SHORT PROC OPTION'

;

proc contents data=x.cancer99 short;

run;

The output from the above procedures is shown on the right. Introduction to SAS? Mike Zdeb (send comments, corrections to: [email protected]) #73 Before moving on to using the data set CANCER99 in various procedures, you can use another procedure to change all the variable names to uppercase and to add labels to the data set. SAS data sets have two parts: a header that contains information about the variables and observations in the data set;

the actual data . If you want to change the contents of information that resides in the header of the data set, the most efficient method is to use PROC DATASETS. Some of the information that resides in the header includes: variable names;

variable labels;

if a format is assiociated with one or more variables in the data set. ...Example 6.4... libname x k:\epi514\datasets ;

proc datasets lib=x nolist;

? modify cancer99;

? label ? county = '

GAZETTEER COUNTY NUMBER'

age = '

AGE AT DEATH (YEARS)'

cause = '

ICD-10 CAUSE OF DEATH'

place = '

WHERE DEATH OCCURRED'

;

rename ? county = COUNTY cause = CAUSE age = AGE gender = GENDER place = PLACE ;

quit;

? Most SAS procedures require that a data set be specified after the PROC name. PROC DATASETS requires you to specify a library where your data set is located ?. The default behavior of the procedure is to produce in the LOG a list all data sets in that library. The NOLIST option suppresses that list ?. The MODIFY statement says that you want to make changes to a specific data set ?. The LABEL statement looks like the one you have seen in previous examples within data steps, however this time it is in a PROC ?. The RENAME statement changes the names to uppercase (old name = new name) ?. The procedure ends with a QUIT (not a RUN) statement ?. The addition of labels and renaming of variables could also have been accomplished in a data step, but that data step also would have read and written all the observations in the data set just to change some header information ... a less efficient approach ... data x.cancer99;

set x.cancer99. label ;

rename ;

run;

If you want to alter a data set and add/remove labels, change variable names, or add/remove formats, use PROC DATASETS, not a data step. There are many other tasks you can accomplish with PROC DATASETS, but these are enough for you to know (many SAS users never use the procedure so you are already ahead of them knowing only this much). Now that the data set has new variable names and labels, the last item is to show what all the values of the variables mean. There are too many county codes to list. The values of both age and cause are explained in the labels in example 6.4. That leaves two variables that have codes that need explanation, gender and place. Introduction to SAS? Mike Zdeb (send comments, corrections to: [email protected]) #74 variable values gender 1=male, 2=female place A=hospital (DOA), B=hospital (ER), C=hospital (outpatient), D=hospital (inpatient), E=other institution, F=decedent'

s residence, G=other private home, H=other non-institution, N=not- in-hospital, Z=unknown (or not classifiable) ...PROC PRINT/REPORTING... There are numerous PROCs that can be used to create reports in SAS. If a procedure cannot produce the type of output you want, you can use a data step to create a custom report. One of the easiest ways to create a report is with PROC PRINT. As stated in the SAS online help... The PRINT procedure prints the observations in a SAS data set for simple reports. PROC PRINT prints a listing of the values of some or all of the variables in a SAS data set. You can produce customized reports using procedure options and statements. The default behavior of PROC PRINT is to print all variables and all observations. If variables are formatted, the formatted values are printed ... proc print data=x.cancer99;

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