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.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: