data oneside keys(keep=id label);
set knee;
by id;
if first.id and last.id then output oneside;
else do;
if last.id and date=lag(date) then do;
label=1; output keys;
end;
else if last.id then do;
label=2; output keys;
end;
end;
run;
data samedate diffdate;
merge knee keys;
by id;
if label=1 then output samedate;
else if label=2 then output diffdate;
drop label;
run;[/code:98de9]
Too simple, without any challenge.
No taste at all. <!-- s:roll: --><img src="{SMILIES_PATH}/icon_rolleyes.gif" alt=":roll:" title="Rolling Eyes" /><!-- s:roll: -->
There are both logical and syntx errors in the sample code. <!-- s:oops: --><img src="{SMILIES_PATH}/icon_redface.gif" alt=":oops:" title="Embarassed" /><!-- s:oops: -->
Check out the revised code above #2.
[quote:ac0fc]Too simple, without any challenge.
No taste at all.[/quote:ac0fc]
It is better to share your GOOD idea and kindly help others. Here is not just for the challenge and competition. <!-- s8) --><img src="{SMILIES_PATH}/icon_cool.gif" alt="8)" title="Cool" /><!-- s8) -->
We'd like to see your sample or hint in the simpler and more efficient way. Thx.
data oneside samedate diffdate;
set ahuige;drop flag;
by id date;
flag=first.id+last.id+first.date+last.date;
if flag =4 then output oneside;
if flag =2 then output samedate;
if flag =3 then output diffdate;
run;[/code:5f279]
不知道为了什么,忧愁它围绕着我.........................
[quote:a8827]flag=first.id+last.id+first.date+last.date;[/quote:a8827]
<!-- s:o --><img src="{SMILIES_PATH}/icon_surprised.gif" alt=":o" title="Surprised" /><!-- s:o --> it is realy good trick and is rare to see this way for grouping.