DATA Step, Macro, Functions and more

Difference between in inobs and outobs

Reply
New Contributor
Posts: 2

Difference between in inobs and outobs

inobs and outobs showing the same no. of rows in the table. so what is the difference between them?

Trusted Advisor
Posts: 1,848

Re: Difference between in inobs and outobs

Posted in reply to priyankachauhan

in some cases you may want to split observations - e.g write out per date in a range of dates.

in other case you may want to filter your input and select output according to some rules.

in both cases inobs will differ from outobs.

Super User
Posts: 2,046

Re: Difference between in inobs and outobs

Posted in reply to priyankachauhan

Hi @priyankachauhan@Shmuel is very kind enough to explain how it works. I am sure, you may or may not understand a lot of concepts if you are a beginner. I found it very hard when i was a beginner 5 years ago. I suggest you to get a copy of this amazing book which has everything that you want and more-

 

PROC SQL: Beyond the Basics Using SAS®, Second Edition
PROC SQL: Beyond the Basics Using SAS®, Second Edition
In Stock
Publisher: SAS Institute
Super User
Posts: 23,958

Re: Difference between in inobs and outobs

Posted in reply to priyankachauhan

In the simplest cases they are the same. But as soon as you complicate things they are not. 

 

They do what it sounds like it does, one controls how many records are read, InOBS) and one controls how many records are output. Since the number of records read obviously affects the outcome they are very different. 
Here's an example of the exact same code and INOBS=2 and OUTOBS=2 in each run. Check the output.

 

title 'OutObs demo';
proc sql outobs=2;
select age, count(*)
from sashelp.class
group by age
order by age desc;
;
quit;


title 'InObs demo';
proc sql inobs=5;
select age, count(*)
from sashelp.class
group by age
order by age desc;
;
quit;

Results:

 

Screen Shot 2017-12-10 at 12.02.47 PM.png

 

 

Ask a Question
Discussion stats
  • 3 replies
  • 1853 views
  • 3 likes
  • 4 in conversation