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
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?
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
@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
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;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.