02-16-2018 10:18 AM - edited 02-16-2018 10:21 AM
If you sort a data set and in a data step when you specify by variable then sas creates two automatic variables back end they are first.by variable and last.by variable.
first.by variable value is=1 for the first observation in a dataset and rest of all the by group will be =0 except last.by variable. that will be one
You can observe it by writing example
proc sort data=ds;
if first.sex and last.x then flag=1;
Need further help from the community? Please ask a new question.