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

data excess;

input id n1;

cards;

10 10

10 20

10 20

10 30

10 40

10 40

10 50

;

run;

now using proc sort separate and store  only unique records in dataA and all other records in dataB .

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

I think that the following will achieve what you want:

proc sort data = excess ;

  by id n1;

run;

data want dups;

  set excess;

  by id n1;

  if first.n1 and last.n1 then output want;

  else output dups;

run;

View solution in original post

5 REPLIES 5
Jagadishkatam
Amethyst | Level 16

try

proc sort data = excess out=wantdupout=dups nodupkey;

by id n1;

run;

the want dataset have unique records and dups have all other records. Hope this helps.

Thanks,

Jagadish

Thanks,
Jag
vshn
Calcite | Level 5

dataset want should be like this

id        n1

10     10

10     30

10     50

and dataset dups

id    n1

10      20

10      20

10      40

10      40

Jagadishkatam
Amethyst | Level 16

Thanks for providing the desired output. please try

dups dataset has duplicate records and unique will have unique records.

proc sort data=excess out=dups UNIQUEOUT= unique NOUNIQUEKEY;

by id n1;

run;

Thanks,

Jag

Thanks,
Jag
art297
Opal | Level 21

I think that the following will achieve what you want:

proc sort data = excess ;

  by id n1;

run;

data want dups;

  set excess;

  by id n1;

  if first.n1 and last.n1 then output want;

  else output dups;

run;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 5 replies
  • 8135 views
  • 0 likes
  • 3 in conversation