BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
katariasarthak
Obsidian | Level 7

Hi,

 

I wanted to know the difference between obs and outobs.

 

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
s_lassen
Meteorite | Level 14

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).

View solution in original post

4 REPLIES 4
PaigeMiller
Diamond | Level 26

Please provide some context for this question.

--
Paige Miller
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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:

http://support.sas.com/documentation/cdl/en/ledsoptsref/69751/HTML/default/viewer.htm#p0h5nwbig8mobb...

 

And for outobs:

http://www2.sas.com/proceedings/sugi23/Handson/p130.pdf

 

Kurt_Bremser
Super User

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.

s_lassen
Meteorite | Level 14

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).

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 32661 views
  • 2 likes
  • 5 in conversation