Hi SAS Forum,
Of this data set, I wanted to separate only the subjects having multiple records.
data have;
informat Current_date date9.;
input Bank_number Account_number Current_date Product $ 25-35 Balance Arrears_Band $ 43-49;
Format Current_date date9.;
cards;
10 1000000000 31MAR2010 Personal OD 78.72 Current
10 1000000000 31MAY2010 Personal OD 62.84 Current
20 1000000000 31MAY2010 Personal OD 52.84 Current
;
run;
Answer:
I should get the following data set.
Obs Current_date Bank_number Account_number Product Balance Arrears_Band
10 1000000000 31MAR2010 Personal OD 78.72 Current
10 1000000000 31MAY2010 Personal OD 62.84 Current
My effort
proc sort data=have out= have_sorted;
by bank_number account_number current_date;
run;
data want;
set have_sorted;
by bank_number account_number current_date;
if not first.account_number and last.account_number then output want;
run;
Problem:
I do not get the correct records.
Could any one help me.
Thanks
Mirisage
try:
data have;
informat Current_date date9.;
input Bank_number Account_number Current_date Product $ 25-35 Balance Arrears_Band $ 43-49;
Format Current_date date9.;
cards;
10 1000000000 31MAR2010 Personal OD 78.72 Current
10 1000000000 31MAY2010 Personal OD 62.84 Current
20 1000000000 31MAY2010 Personal OD 52.84 Current
;
run;
proc sort data=have out= have_sorted;
by bank_number account_number current_date;
run;
data want;
set have_sorted;
by bank_number account_number current_date;
if first.account_number and last.account_number then delete;
run;
proc print;run;
try:
data have;
informat Current_date date9.;
input Bank_number Account_number Current_date Product $ 25-35 Balance Arrears_Band $ 43-49;
Format Current_date date9.;
cards;
10 1000000000 31MAR2010 Personal OD 78.72 Current
10 1000000000 31MAY2010 Personal OD 62.84 Current
20 1000000000 31MAY2010 Personal OD 52.84 Current
;
run;
proc sort data=have out= have_sorted;
by bank_number account_number current_date;
run;
data want;
set have_sorted;
by bank_number account_number current_date;
if first.account_number and last.account_number then delete;
run;
proc print;run;
Because NOT take precedence over AND in the order of operations. Add some () to group for you.
if not (first.account_number and last.account_number) then output want;
Hi Linlin and Tom,
Many thanks to both of you.
Both of your suggestions work very well.
I usually post my queries in "SAS Procedures" among the following list of "Available Support Communities".
• SAS Procedures
• SAS Macro Facility, Data Step and SAS Language Elements
• SAS/GRAPH and ODS Graphics
• ODS and Base Reporting
• SAS Web Report Studio
• SAS Enterprise Guide
..................................
...................... and so on.
I cannot find this posting in "SAS Procedures" support community.
Could you please let me know which sub sommunity you will find my posting.
Thank you
Mirisage.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.