SAS System Options |
Valid in: | configuration file, SAS invocation, OPTIONS statement, SAS System Options window |
Category: | Files: SAS Files |
PROC OPTIONS GROUP= | SASFILES |
See: | OBS= System Option under Windows UNIX OpenVMS |
Syntax |
OBS= n | nK | nM | nG | nT | hexX | MIN | MAX |
specifies a number to indicate when to stop processing, with n being an integer. Using one of the letter notations results in multiplying the integer by a specific value. That is, specifying K (kilo) multiplies the integer by 1,024; M (mega) multiplies by 1,048,576; G (giga) multiplies by 1,073,741,824; or T (tera) multiplies by 1,099,511,627,776. For example, a value of 20 specifies 20 observations or records, while a value of 3m specifies 3,145,728 observations or records.
specifies a number to indicate when to stop processing as a hexadecimal value. You must specify the value beginning with a number (0-9), followed by an X. For example, the hexadecimal value F8 must be specified as 0F8x in order to specify the decimal equivalent of 248. The value 2dx specifies the decimal equivalent of 45.
sets the number to 0 to indicate when to stop processing.
sets the number to indicate when to stop processing to the maximum number of observations or records, up to the largest eight-byte, signed integer, which is 263-1, or approximately 9.2 quintillion. This is the default.
Details |
OBS= tells SAS when to stop processing observations or records. To determine when to stop processing, SAS uses the value for OBS= in a formula that includes the value for OBS= and the value for FIRSTOBS=. The formula is
(obs - firstobs) + 1 = results
For example, if OBS=10 and FIRSTOBS=1 (which is the default for FIRSTOBS=), the result is 10 observations or records, that is (10 - 1) + 1 = 10. If OBS=10 and FIRSTOBS=2, the result is nine observations or records, that is, (10 - 2) + 1 = 9.
OBS= is valid for all steps during your current SAS session or until you change the setting.
You can also use OBS= to control analysis of SAS data sets in PROC steps.
If SAS is processing a raw data file, OBS= specifies the last line of data to read. SAS counts a line of input data as one observation, even if the raw data for several SAS data set observations is on a single line.
Operating Environment Information: The syntax that is shown here applies to the OPTIONS statement. On the command line or in a configuration file, the syntax is specific to your operating environment. For details, see the SAS documentation for your operating environment.
Comparisons |
An OBS= specification from either a data set option or an INFILE statement option takes precedence over the OBS= system option.
While the OBS= system option specifies an ending point for processing, the FIRSTOBS= system option specifies a starting point. The two options are often used together to define a range of observations to be processed.
Examples |
This example illustrates the result of using OBS= to tell SAS when to stop processing observations. This example creates a SAS data set, executes the OPTIONS statement by specifying FIRSTOBS=2 and OBS=12, and executes the PRINT procedure. The result is 11 observations, that is, (12 - 2) + 1 = 11. The result of OBS= in this situation appears to be the observation number that SAS processes last, because the output starts with observation 2, and ends with observation 12, but this result is only a coincidence.
data Ages; input Name $ Age; datalines; Miguel 53 Brad 27 Willie 69 Marc 50 Sylvia 40 Arun 25 Gary 40 Becky 51 Alma 39 Tom 62 Kris 66 Paul 60 Randy 43 Barbara 52 Virginia 72 ; options firstobs=2 obs=12; proc print data=Ages; run;
PROC PRINT Output Using OBS= and FIRSTOBS=
The SAS System 1 Obs Name Age 2 Brad 27 3 Willie 69 4 Marc 50 5 Sylvia 40 6 Arun 25 7 Gary 40 8 Becky 51 9 Alma 39 10 Tom 62 11 Kris 66 12 Paul 60
This example illustrates the result of using OBS= along with WHERE processing. The example uses the data set that was created in Example 1, which contains 15 observations, and the example assumes a new SAS session with the defaults FIRSTOBS=1 and OBS=MAX.
First, here is the PRINT procedure with a WHERE statement. The subset of the data results in 12 observations:
proc print data=Ages; where Age LT 65; run;
PROC PRINT Output Using a WHERE Statement
The SAS System 1 Obs Name Age 1 Miguel 53 2 Brad 27 4 Marc 50 5 Sylvia 40 6 Arun 25 7 Gary 40 8 Becky 51 9 Alma 39 10 Tom 62 12 Paul 60 13 Randy 43 14 Barbara 52
Executing the OPTIONS statement with OBS=10 and the PRINT procedure with the WHERE statement results in 10 observations, that is, (10 - 1) + 1 = 10. Note that with WHERE processing, SAS first subsets the data and then SAS applies OBS= to the subset.
options obs=10; proc print data=Ages; where Age LT 65; run;
PROC PRINT Output Using a WHERE Statement and OBS=
The SAS System 2 Obs Name Age 1 Miguel 53 2 Brad 27 4 Marc 50 5 Sylvia 40 6 Arun 25 7 Gary 40 8 Becky 51 9 Alma 39 10 Tom 62 12 Paul 60
The result of OBS= appears to be how many observations to process, because the output consists of 10 observations, ending with the observation number 12. However, the result is only a coincidence. If you apply FIRSTOBS=2 and OBS=10 to the subset, the result is nine observations, that is, (10 - 2) + 1 = 9. OBS= in this situation is neither the observation number to end with nor how many observations to process; the value is used in the formula to determine when to stop processing.
options firstobs=2 obs=10; proc print data=Ages; where Age LT 65; run;
PROC PRINT Output Using WHERE Statement, OBS=, and FIRSTOBS=
The SAS System 3 Obs Name Age 2 Brad 27 4 Marc 50 5 Sylvia 40 6 Arun 25 7 Gary 40 8 Becky 51 9 Alma 39 10 Tom 62 12 Paul 60
This example illustrates the result of using OBS= for a data set that has deleted observations. The example uses the data set that was created in Example 1, with observation 6 deleted. The example also assumes a new SAS session with the defaults FIRSTOBS=1 and OBS=MAX.
First, here is PROC PRINT output of the modified file:
&proc print data=Ages; run;
PROC PRINT Output Showing Observation 6 Deleted
The SAS System 1 Obs Name Age 1 Miguel 53 2 Brad 27 3 Willie 69 4 Marc 50 5 Sylvia 40 7 Gary 40 8 Becky 51 9 Alma 39 10 Tom 62 11 Kris 66 12 Paul 60 13 Randy 43 14 Barbara 52 15 Virginia 72
Executing the OPTIONS statement with OBS=12, then the PRINT procedure, results in 12 observations, that is, (12 - 1) + 1 = 12:
options obs=12; proc print data=Ages; run;
The SAS System 2 Obs Name Age 1 Miguel 53 2 Brad 27 3 Willie 69 4 Marc 50 5 Sylvia 40 7 Gary 40 8 Becky 51 9 Alma 39 10 Tom 62 11 Kris 66 12 Paul 60 13 Randy 43
The result of OBS= appears to be how many observations to process, because the output consists of 12 observations, ending with the observation number 13. However, if you apply FIRSTOBS=2 and OBS=12, the result is 11 observations, that is (12 - 2) + 1 = 11. OBS= in this situation is neither the observation number to end with nor how many observations to process; the value is used in the formula to determine when to stop processing.
options firstobs=2 obs=12; proc print data=Ages; run;
PROC PRINT Output Using OBS= and FIRSTOBS=
The SAS System 3 Obs Name Age 2 Brad 27 3 Willie 69 4 Marc 50 5 Sylvia 40 7 Gary 40 8 Becky 51 9 Alma 39 10 Tom 62 11 Kris 66 12 Paul 60 13 Randy 43
See Also |
|
|
Copyright © 2011 by SAS Institute Inc., Cary, NC, USA. All rights reserved.