编辑: 向日葵8AS | 2019-07-13 |
run;
would produce a reports with 35,000+ lines, listing the values for the five variables in that data set. A portion of the data set CANCER99 can be printed by using the FIRSTOBS and OBS data set options discussed earlier in chapter 4. ...Example 6.5... title '
A PORTION OF DATA SET CANCER99 (SELECTED BY OBSERVATION NUMBER)'
;
proc print data=x.cancer99 (firstobs=501 obs=510);
? run;
proc print data=x.cancer99 (firstobs=501 obs=510) label obs='
OBSERVATION NUMBER;
? run;
Two data set options are used to limit the output of PROC PRINT to the ten observations from
501 through
510 ?. The output lists observation numbers in the first column, with the order of remaining columns determined by the order of the variables in the data set. Notice that the variable names are all in uppercase, the change made using PROC DATASETS in example 6.4. Also notice that the labels added in example 6.4 are not used. Introduction to SAS? Mike Zdeb (send comments, corrections to: [email protected]) #75 The default behavior of PROC PRINT is to use variable names, not labels as column headings. The LABEL option puts labels rather than variable names as the column headers ?. Also, you can change the default text of '
Obs'
over column one with the OBS option ?. The changes that result from using these two options are shown on the right. In addition to using data set option to limit the number of observations that are printed, you can also use a WHERE statement of data set option (as described in chapter 4). Rather than look at a pre-specified range of observations, you can use a random number function within a WHERE statement (more about functions in a later chapter). ...Example 6.6... title '
A PORTION OF DATA SET CANCER99 (SELECTED RANDOMLY - REPEATABLE)'
;
proc print data=x.cancer99 label;
where ranuni(99) le .0005;
? run;
title '
A PORTION OF DATA SET CANCER99 (SELECTED RANDOMLY - NON-REPEATABLE)'
;
proc print data=x.cancer99 label;
where ranuni(0) le .0005;
? run;
The output from PROC PRINT on the left is the result of using a WHERE statement that contains the RANUNI random number function ?. That function generates uniform (UNI) random (RAN) numbers in the range
0 to 1. If you ask SAS to use an observation each time it is less than .0005, approximately 0.05% of the observations are printed ... if you take 0.05% of the 35,000+ observations in data set CANCER99, you will get approximately
20 observations printed. The argument (the number within the parentheses following RANUNI) is a positive integer, 99, called a seed number. If you use the function again with that number, you will get the same observations printed. The output is repeatable since using the same seed number repeats the same set of random numbers. Introduction to SAS? Mike Zdeb (send comments, corrections to: [email protected]) #76 The output on the right is al........