First. and Last . in sas -
my data table looks :
name amount status 5000 debit 2000 credit 1000 credit b 2000 debit b 1000 debit b 1000 credit
i want output be:
name net_amount status 2000 debit b 2000 debit
how can achieve using first.
, last.
variables? in advance
data a; input name $ amount status $; cards; 5000 debit 2000 credit 1000 credit b 2000 debit b 1000 debit b 1000 credit ; run; proc sort data=a; name status amount; run; data by_name_first_obs by_name_and_status_first_obs by_name_last_obs by_name_and_status_last_obs; set a; name status; if first.name output by_name_first_obs; if last.name output by_name_last_obs; if first.status output by_name_and_status_first_obs; if last.status output by_name_and_status_last_obs; run;
Comments
Post a Comment