BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
dunga
Obsidian | Level 7

/*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

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
PROC SURVEYSELECT DATA=want OUT=need METHOD=SRS
  SAMPSIZE=2 SEED=1234567;

cluster Account_number;

RUN;

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

Can you please show us the output you want for this data?

--
Paige Miller
Ksharp
Super User
PROC SURVEYSELECT DATA=want OUT=need METHOD=SRS
  SAMPSIZE=2 SEED=1234567;

cluster Account_number;

RUN;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 601 views
  • 0 likes
  • 3 in conversation