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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 869 views
  • 3 likes
  • 4 in conversation