BookmarkSubscribeRSS Feed
ravindra2
Fluorite | Level 6

hi

i have one dataset i want log as there is a duplicate record tn dataset and that duplicate dataset should be printed in log window.

data lb;
input usubjid lbdtc $ 16. lbtptnum rbc $ wbc $ visit;
cards;
101 01-10-2018T10:15 1 1 1 1
101 01-10-2018T10:20 2 2 2 1.01
101 01-10-2018T10:20 2 2 2 1.01
;

thank you

4 REPLIES 4
PeterClemmensen
Tourmaline | Level 20

I'm not following. You have a duplicate record in your data set. What do you want to be printed in the log? The data set name? The duplicate record?

ravindra2
Fluorite | Level 6

there should be a warning that 'lb dataset having duplicate record'

 

next task is 

 

that duplicate record which is there in lb dataset should also have to print in log

Kurt_Bremser
Super User

@ravindra2 wrote:

there should be a warning that 'lb dataset having duplicate record'

 



Since that is not a native problem condition for SAS, you have to write code that detects this, eg

proc sort
  data=have
  out=sort
  dupout=test
  nodupkey
;
by key;
run;

data _null_;
set test;
put 'Duplicate observation detected!';
stop;
run;

If no duplicates are there, the data step will stop on its own when the set statement encounters the EOF condition.

 


 

next task is 

 

that duplicate record which is there in lb dataset should also have to print in log


Don't do that. If you apply that to a large dataset, your log file will grow out of proportion, which takes space and time. If you need documentation, use a reference to the dupout dataset (and write that to a permanent library).

 

Edit: added the nodupkey option in the proc sort statement

singhsahab
Lapis Lazuli | Level 10
data lb;
input usubjid lbdtc $ 16. lbtptnum rbc $ wbc $ visit;
cards;
101 01-10-2018T10:15 1 1 1 1
101 01-10-2018T10:20 2 2 2 1.01
101 01-10-2018T10:20 2 2 2 1.01
;
run;


proc sort data=lb dupout=want nodupkey;
by _all_;
run;

data _null_;
set want;
put _all_;
run;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 4 replies
  • 738 views
  • 2 likes
  • 4 in conversation