Hello team,
Can any one explain this?
When an observation is the first in a by group, sas set the value of first.variable to 1. This happens when the value of the variable changed from the previous observation.
b. For all other observations in the by group. they value of first.variable is 0.
Does section b mean that all other observations in the same group or other groups?
Please elaborate this?
Regards,
blueblue
Try it and see.
proc sort data=sashelp.class out=class;
by sex;
run;
data test;
set class;
by sex;
first_sex = first.sex;
last_sex = last.sex;
run;
proc print;
var first_sex last_sex sex name;
run;
Try it and see.
proc sort data=sashelp.class out=class;
by sex;
run;
data test;
set class;
by sex;
first_sex = first.sex;
last_sex = last.sex;
run;
proc print;
var first_sex last_sex sex name;
run;
> When an observation is the first in a by group, sas set the value of first.variable to 1. ... For all other observations in the by group. they value of first.variable is 0.
That's how this is supposed to work. Your question is nuclear.
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!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.