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

Dear all,

I have a huge dataset with the following info

ID_AID_BEXP_AEXP_BCREATION_DATERAT_X
147976667KMH124OCT2011:13:52:224
147976667                     06AUG2012:22:44:3017
55112366667ADN103JUN2012:08:05:293
147976667MR0127MAR2012:08:56:0817
147976667JHM124OCT2011:13:51:464
147976667JHM224OCT2011:13:51:434
55112366667ADN103JUN2013:10:54:193

I need to flag or save in a different dataset all the observations that for variable EXP_A have different EXP_B and RAT_X

Please note that generally the EXP_A is grouped under ID_A & ID_B, although it seems that the same EXP_A can be found under two or more different groupings by ID_A & ID_B values (I do not know whether this is an error or not )

Thank you in advance.

Best regards

Nikos

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

If I understand the problem statement, you may want something like this:

data have;

input  ID_A ID_B EXP_A $ EXP_B $ CREATION_DATE $ RAT_X;

drop creation_date;

datalines;

1 4797 6667 KMH1 24OCT2011:13:52:22 4

1 4797 6667 .       06AUG2012:22:44:30 17

55 11236 6667 ADN1 03JUN2012:08:05:29 3

1 4797 6667 MR01 27MAR2012:08:56:08 17

1 4797 6667 JHM1 24OCT2011:13:51:46 4

1 4797 6667 JHM2 24OCT2011:13:51:43 4

55 11236 6667 ADN1 03JUN2013:10:54:19 3

;

proc sql;

create table flagged as

select ID_A, ID_B, EXP_A

from have

group by ID_A, ID_B, EXP_A

having count(distinct catx("-", EXP_B, RAT_X)) > 1;

select * from flagged;

quit;

PG

PG

View solution in original post

1 REPLY 1
PGStats
Opal | Level 21

If I understand the problem statement, you may want something like this:

data have;

input  ID_A ID_B EXP_A $ EXP_B $ CREATION_DATE $ RAT_X;

drop creation_date;

datalines;

1 4797 6667 KMH1 24OCT2011:13:52:22 4

1 4797 6667 .       06AUG2012:22:44:30 17

55 11236 6667 ADN1 03JUN2012:08:05:29 3

1 4797 6667 MR01 27MAR2012:08:56:08 17

1 4797 6667 JHM1 24OCT2011:13:51:46 4

1 4797 6667 JHM2 24OCT2011:13:51:43 4

55 11236 6667 ADN1 03JUN2013:10:54:19 3

;

proc sql;

create table flagged as

select ID_A, ID_B, EXP_A

from have

group by ID_A, ID_B, EXP_A

having count(distinct catx("-", EXP_B, RAT_X)) > 1;

select * from flagged;

quit;

PG

PG

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
  • 1 reply
  • 666 views
  • 0 likes
  • 2 in conversation