BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Wken1122
Obsidian | Level 7

Hi,
Can someone explain what does this mean?

FIRST_REGNUMBER=FIRST.REGNUMBER ;
LAST_REGNUMBER=LAST.REGNUMBER;

I had tried to read the explanation from different source but I am still confuse.

Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

A temporary flag is added to the data, called first.<variable> and last.<variable> for each variable in the by group, this flag can then be used to determine if the record is the first or last occurence within the by group.

There are many guidance documents out there about this:

https://onlinecourses.science.psu.edu/stat481/node/9

For example.

 

Also, as a tip, do not code all in uppercase.

 

View solution in original post

3 REPLIES 3
Criptic
Lapis Lazuli | Level 10

It gives you the first/last row of a group. A quick example:

data aa1;
    set sashelp.cars;
    by make;

    if first.make then
        output;
    else if last.make then
        output;
run;

Gives you a table with only the first and last row per make in the table

RW9
Diamond | Level 26 RW9
Diamond | Level 26

A temporary flag is added to the data, called first.<variable> and last.<variable> for each variable in the by group, this flag can then be used to determine if the record is the first or last occurence within the by group.

There are many guidance documents out there about this:

https://onlinecourses.science.psu.edu/stat481/node/9

For example.

 

Also, as a tip, do not code all in uppercase.

 

Kurt_Bremser
Super User

Since the automatic first. and last. variables (which are created when a by statement is present in the data step) are not included in any output data, these assignments are a technique to make the values visible in the output dataset.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 3 replies
  • 1448 views
  • 3 likes
  • 4 in conversation