BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
cosmid
Lapis Lazuli | Level 10

Hi,

 

From the definition of the two:

INOBS= is restricting the number of input rows

OBS= is specifying the last observation

 

Based on that, I couldn't think of a scenario where the two are different. Are they logically the same thing?

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
yabwon
Onyx | Level 15

1) INOBS= is Proc SQL spacific,

2) OBS= is global option and data set option

3) INOBS= produces a warning

4) OBS= can overwrite INOBS=

 

See this:

1    proc sql INOBS=10;
2      select * from sashelp.class;
WARNING: Only 10 records were read from SASHELP.CLASS due to INOBS= option.
3    quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


4
5
6    proc sql INOBS=10;
7      select * from sashelp.class(obs=5);
8    quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


9
10   proc sql;
11     select * from sashelp.class(obs=5);
12   quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds


13
14   data test1;
15     set sashelp.class(obs=5);
16   run;

NOTE: There were 5 observations read from the data set SASHELP.CLASS.
NOTE: The data set WORK.TEST1 has 5 observations and 5 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


17
18   data test2;
19     set sashelp.class(inobs=5);
                         -----
                         22
ERROR 22-7: Invalid option name INOBS.

20   run;

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.TEST2 may be incomplete.  When this step was stopped there were 0
         observations and 0 variables.
WARNING: Data set WORK.TEST2 was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds

Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



View solution in original post

2 REPLIES 2
yabwon
Onyx | Level 15

1) INOBS= is Proc SQL spacific,

2) OBS= is global option and data set option

3) INOBS= produces a warning

4) OBS= can overwrite INOBS=

 

See this:

1    proc sql INOBS=10;
2      select * from sashelp.class;
WARNING: Only 10 records were read from SASHELP.CLASS due to INOBS= option.
3    quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


4
5
6    proc sql INOBS=10;
7      select * from sashelp.class(obs=5);
8    quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


9
10   proc sql;
11     select * from sashelp.class(obs=5);
12   quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds


13
14   data test1;
15     set sashelp.class(obs=5);
16   run;

NOTE: There were 5 observations read from the data set SASHELP.CLASS.
NOTE: The data set WORK.TEST1 has 5 observations and 5 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


17
18   data test2;
19     set sashelp.class(inobs=5);
                         -----
                         22
ERROR 22-7: Invalid option name INOBS.

20   run;

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.TEST2 may be incomplete.  When this step was stopped there were 0
         observations and 0 variables.
WARNING: Data set WORK.TEST2 was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds

Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



SASJedi
SAS Super FREQ

inObs= specifies the total number of rows to read in. obs= specifies the row number where you should stop reading. The firstObs= option specifies the first row of data tobe read, and it's easier to see the difference between obs= and inObs= if you apply firstOBS= in conjunction with those options and compare the results: 

/* inObs= vs obs= with firstObs=*/
proc sql inobs=50 number;
title 'InObs=50, firstObs=20';
select *
	from sashelp.cars(firstObs=20)
;
quit;

title 'obs=50, firstObs=20';
proc sql number;
title 'obs=50, firstObs=20';
select *
	from sashelp.cars(firstObs=20 obs=50)
;
quit;

Note that the first query returns 50 rows, but the second query only returns 31 rows.

 

Check out my Jedi SAS Tricks for SAS Users

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 1233 views
  • 4 likes
  • 3 in conversation