1
votes

I am working on a problem and there is something that I do not understand.

The data set sasdata.prdsales contains 5,000 observations.

 libname sastemp 'SAS-data-library';
      options obs=500;
      proc print data=sasdata.prdsales (firstobs=100);
 run; 
 options obs=max;
 proc means data=sasdata.prdsales(firstobs=500);
 run;

My understanding is that OBS= specifies the number of observations SAS will process, so for the PROC PRINT statement I am thinking that starting with observation number 100, ending at observation number 499, 500 observations are going to be processed.

For the PROC MEANS step, the OBS=MAX instructs SAS to process all observations, but since the starting observation is from 500, the total number of observations will be from 500 to 5,000 which is 4,501 observations.

However, the answer to this questions says that the PROC PRINT has 501 observations and I am confused...

Thank you.

2
Where does the question originate from? It seems wrong to me as well, but not for the reasons you're thinking.Reeza
It is from an exam from Acualtests.com Exam A00-201 Question 2. I only have the pdf that was created based on these problems so there definitely are some typos and odd displays of data... but I do not want to result to just saying that it is a typo yet.hyg17
It isn't a typo, it's just wrong, but you get what you pay for. I would highly suggest the free SAS e-courses if you haven't already taken those.Reeza

2 Answers

5
votes

OBS= is not the number of observations to process, you should instead think of it as a LASTOBS= option (which does not exist)

OBS=500 alone will process 500 rows because of implicit FIRSTOBS of 1.

For the effective case of FIRSTOBS=100 OBS=500 the rows 100 through 500 will be processed, or 401 rows.

1
votes

Use smaller numbers so it is easier to check on your fingers.

1    options obs=10;
2    proc print data=sashelp.class(firstobs=5);
3    run;

NOTE: There were 6 observations read from the data set SASHELP.CLASS.

Obs    Name       Sex    Age    Height    Weight

  5    Henry       M      14     63.5      102.5
  6    James       M      12     57.3       83.0
  7    Jane        F      12     59.8       84.5
  8    Janet       F      15     62.5      112.5
  9    Jeffrey     M      13     62.5       84.0
 10    John        M      12     59.0       99.5

So it started with obs #5 and stopped at obs #10. 10-5+1=6.

So for your problem you can calculate 500-100+1 = 401.

Another way to think of it is that by setting FIRSTOBS=N you are tell it to skip N-1 observations. So so FIRSTOBS=100 means to skip 99 observations. 500-99=401.