BookmarkSubscribeRSS Feed
Oliver2
Calcite | Level 5

Hello!

I had a quick look, but couldn't find any questions similar to this, so hopefully I'm not bringing up old questions.

What is the reason the the POINT= option only works when set to a set to equal a variable (eg the obsnum below), rather than just setting it to equal an integer?

eg why does this work

data OJOSData;

  obsnum=6;

  set grades point=obsnum;

  output;

  stop;

run;

but this doesn't?

data OJOSData;

  set grades point=6;

  output;

  stop;

run;

I was just wondering what the underlying reason is.

Many thanks

Oliver

PS the SAS University software is a godsend for testing things like this that puzzle me

4 REPLIES 4
SASKiwi
PROC Star

There are already options for reading a specific observation or range of observations. FIRSTOBS= for the first record to be read and OBS= for the last record to be read.

POINT= is for identifying observations by formula/calculation.

data want;

  set have (firstobs = 6 obs = 6);

run;

Oliver2
Calcite | Level 5

Right!  It's interesting isn't it how certain rules work in certain ways.

With POINT you HAVE to use a variable, but with firstobs you CANNOT use a variable.  At least I can't make it work...

data OJOSData;

  fobs=7;

  set grades (firstobs=fobs);

run;

Thanks SASKiwi, something for me to think about!

SASKiwi
PROC Star

That's right - refer to the documentation for the correct use of each option.

gergely_batho
SAS Employee

obs= and firstobs= dataset options are designed to subset the data before it reaches the data step or a procedure. As they are data set options, they work almost in any circumstances. For example in a proc step. Obviously you don't have data step variables in a proc step.  obs= and  firstobs= can subset the observations very efficiently.

point= works only in a data step, it is an option of the set statement. It is designed to allow random/direct access to specific observations.

For example if you want to read the 10th, 20th and than again the 10th observation.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 8830 views
  • 0 likes
  • 3 in conversation