/*I need to separate the "by group of accts" where Arrears_Band at least once has “writoff” value. */
data have;
informat Current_date date9.;
Input Current_date Account_number Arrears_Band :$15.;
Format Current_date date9.;
cards;
31MAY2011 111 NPNA
30JUN2011 111 writoff
31JUL2011 111 NPNA
31AUG2011 111 NPNA
30SEP2011 111 NPNA
31OCT2011 111 NPNA
30NOV2011 111 NPNA
31DEC2011 111 NPNA
31JAN2012 111 NPNA
31DEC2011 222 NPNA
31JAN2012 222 NPNA
30NOV2010 333 NPNA
31DEC2010 333 NPNA
31JAN2011 333 NPNA
28FEB2011 333 NPNA
31MAR2011 333 writoff
30APR2011 333 NPNA
31MAY2011 333 NPNA
30JUN2011 333 NPNA
31JUL2011 333 NPNA
31AUG2011 333 NPNA
30SEP2011 333 NPNA
31OCT2011 333 NPNA
30NOV2011 333 NPNA
31DEC2011 333 NPNA
31JAN2012 333 NPNA
28FEB2010 444 Current
31MAR2010 444 30 - 60
30APR2010 444 30 - 60
31MAY2010 444 Current
30JUN2010 444 Current
31JUL2010 444 Current
31AUG2010 444 Current
30SEP2010 444 Current
31OCT2010 444 Current
30NOV2010 444 Current
31DEC2010 444 Current
31JAN2011 444 1 - 30
28FEB2011 444 30 - 60
31MAR2011 444 60 - 90
30APR2011 444 90 +
31MAY2011 444 90 +
30JUN2011 444 90 +
31JUL2011 444 NPNA
31AUG2011 444 NPNA
30SEP2011 444 NPNA
31OCT2011 444 NPNA
30NOV2011 444 NPNA
31DEC2011 444 NPNA
31JAN2012 444 NPNA
28FEB2010 555 30 - 60
31MAR2010 555 30 - 60
30APR2010 555 60 - 90
31MAY2010 555 NPNA
31JAN2012 666 writoff
31JAN2012 777 NPNA
;
run;
/*Below code does do the job and it separates three "by group of accts", accts 111, 333 and 666*/
data want;
merge have (where=(Arrears_Band='writoff') in=a)
have (in=b);
by account_number;
if a and b;
run;
/*Q: Out of the above three "by group of accts", how could I randomly select only 2 bygroups of accts (my original dataset is having several thousand records)?*/
/*Below proc surveyselect selects only 2 individual rows and does not select 2 by groups*/
PROC SURVEYSELECT DATA=want OUT=need METHOD=SRS
SAMPSIZE=2 SEED=1234567;
RUN;
/*Thanks
Mirisa
PROC SURVEYSELECT DATA=want OUT=need METHOD=SRS
SAMPSIZE=2 SEED=1234567;
cluster Account_number;
RUN;
Can you please show us the output you want for this data?
PROC SURVEYSELECT DATA=want OUT=need METHOD=SRS
SAMPSIZE=2 SEED=1234567;
cluster Account_number;
RUN;
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
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.
Ready to level-up your skills? Choose your own adventure.