SAS- Problem-3:OPTIONS OBS & FIRST OBS



OPTIONS OBS & FIRST OBS

Problem: I have a dataset ‘MYDATA’ which has 1000 observations. I perform the following operations on it.
OPTIONS OBS=MAX;

DATA MYDATA_OBSERVATIONS;
SET MYDATA(OBS=100);
RUN;

OPTIONS FIRSTOBS = 5 OBS =20;

PROC SORT DATA = MYDATA_OBSERVATIONS OUT =MYDATA_OBSERVATIONS_SORTED;
BY MANAGERCODE;
RUN;

PROC PRINT DATA = MYDATA_OBSERVATIONS_SORTED;

How many observations will get printed after this process?
Solution: Here’s the log for this code.
569 OPTIONS OBS=MAX;
570 DATA MYDATA_OBSERVATIONS;
571 SET MYDATA(OBS=100);
572 RUN;
NOTE: There were 100 observations read from the data set WORK.MYDATA.
NOTE: The data set WORK.MYDATA_OBSERVATIONS has 100 observations and 22 variables.
NOTE: DATA statement used (Total process time):
real time 0.06 seconds
cpu time
555 OPTIONS FIRSTOBS = 5 OBS =20;
556 PROC SORT DATA = MYDATA_OBSERVATIONS OUT =MYDATA_OBSERVATIONS_SORTED;
557 BY ACCOUNTMANAGERCODE;
558 RUN;
NOTE: There were 16 observations read from the data set WORK.MYDATA_OBSERVATIONS.
NOTE: The data set WORK.MYDATA_OBSERVATIONS_SORTED has 16 observations and 22 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.17 seconds
cpu time 0.12 seconds
So 16 observatioins will be printed, this is because first OBS=20 is takenand then SAS will start reading from the 5th observation.

  1. gravatar

    # by Kiran - October 4, 2009 at 9:03 PM

    is there a way to delete the last observation of a dataset...?

Blog Widget by LinkWithin

Search this blog..

Loading