Hi,
I have the following dataset:
RECNR OPR
123 XDFW
123 EDG03
1245 XDFW
1245 EDG03
1245 KFE011
1245 RTF00
So I have several observations with equal RECNR but different OPR value.
I want to keep observations with equal RECNR (e.g. 1245) that have the OPR values of EDG03 AND XDFW.
Can anyone help?
Thanks a lot!
One way:
data want;
set have;
by recnr;
where opr in ('XDFW', 'EDG03');
if first.recnr=0 or last.recnr=0;
run;
It's probably clear to you (but not to me) whether or not you want to keep other OPR values when the RECNR contains one of the values you are looking for. This code keeps only the two values you specified, and requires there to be more than 1 observation containing a value in the list.
One way:
data want;
set have;
by recnr;
where opr in ('XDFW', 'EDG03');
if first.recnr=0 or last.recnr=0;
run;
It's probably clear to you (but not to me) whether or not you want to keep other OPR values when the RECNR contains one of the values you are looking for. This code keeps only the two values you specified, and requires there to be more than 1 observation containing a value in the list.
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!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.