Hi,
I wanted to know the difference between obs and outobs.
Thanks.
OBS can be a system option or a dataset option, it limits the number of observarions read in a proc or a datastep. OBS normally decides the number of the last observation read. If, however, you have tables with "holes" in them (deleted observations), the results can vary a bit.
Look at this:
data x;
do i=1 to 10;
output;
end;
run;
proc sql; /* delete the first observation */
delete from x where i=1;
quit;
options obs=5;
data y;
set x;
run;
data z;
set x(firstobs=3);
run;
The Y table contains 5 observations, which are i=2 to 6. Because the read started from the beginning, SAS new that an observation was deleted, and adjusted the number to read accordingly.
But the Z table contains 3 observations (as expected), with I values from 3 to 5 (not as expected), because SAS did not read from the start of the table (because of the FIRSTOBS option) ,and therefore did not realize that the first observation was deleted.
The OUTOBS option is ony used in PROC SQL. It can used either in the SQL invocation ("proc SQL OUTOBS=<number>;") or in a RESET Statement. It does not limit the amount of processing done, except that processing stops once the desired number of observations has been output in the statement.
Compare this:
options obs=1;
proc sql;
select sum(age) from sashelp.class;
quit;
options obs=max;
proc sql outobs=1;
select sum(age) from sashelp.class;
quit;
The first PROC SQL call will return 14, which is the age of the first person in the dataset (only one record is read). The second SQL call will give you 253, which is the sum of all the ages in the class (OUTOBS does nothing here, as only one sum is to be returned anyway, all the records are read).
Please provide some context for this question.
Thats very vague, I mean the difference could be that the first has three less characters? Have you read the manual for these items in relevance to where/how you are using them. For instance:
And for outobs:
http://www2.sas.com/proceedings/sugi23/Handson/p130.pdf
Maxim 6: Google is your friend.
Do a google search each for
sas outobs
sas obs
and you'll have enough information that will show you the answer.
OBS can be a system option or a dataset option, it limits the number of observarions read in a proc or a datastep. OBS normally decides the number of the last observation read. If, however, you have tables with "holes" in them (deleted observations), the results can vary a bit.
Look at this:
data x;
do i=1 to 10;
output;
end;
run;
proc sql; /* delete the first observation */
delete from x where i=1;
quit;
options obs=5;
data y;
set x;
run;
data z;
set x(firstobs=3);
run;
The Y table contains 5 observations, which are i=2 to 6. Because the read started from the beginning, SAS new that an observation was deleted, and adjusted the number to read accordingly.
But the Z table contains 3 observations (as expected), with I values from 3 to 5 (not as expected), because SAS did not read from the start of the table (because of the FIRSTOBS option) ,and therefore did not realize that the first observation was deleted.
The OUTOBS option is ony used in PROC SQL. It can used either in the SQL invocation ("proc SQL OUTOBS=<number>;") or in a RESET Statement. It does not limit the amount of processing done, except that processing stops once the desired number of observations has been output in the statement.
Compare this:
options obs=1;
proc sql;
select sum(age) from sashelp.class;
quit;
options obs=max;
proc sql outobs=1;
select sum(age) from sashelp.class;
quit;
The first PROC SQL call will return 14, which is the age of the first person in the dataset (only one record is read). The second SQL call will give you 253, which is the sum of all the ages in the class (OUTOBS does nothing here, as only one sum is to be returned anyway, all the records are read).
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: