SAS Procedures

Help using Base SAS procedures
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.

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

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
  • 8277 views
  • 0 likes
  • 3 in conversation