I want to identify the duplicate %age as per month Starting from Jan until Dec.
I could find the duplicates and put in separate data set by the following code:
proc sort data = pankaj.UM_yield_detail_mm
dupout= Duplicate_NODUPS
nodupkey ;
by batch_id ;
run ;
Basically, I want to have duplicate count and %age of duplicates based on the original data set which contains Variable "Batch_ID". if in case I don't want to create another other data set. Is it possible or I have to create another data set.
Batch_ID |
8809510976 |
8807226488 |
8809932795 |
8810161136 |
8810161136 |
8810172306 |
8809510752 |
8809436613 |
8809510734 |
8809510734 |
8810207111 |
8809510734 |
8810160901 |
8810207111 |
8809724861 |
8807221194 |
8807221200 |
8807221205 |
8807221217 |
8807221217 |
8807221217 |
8807221217 |
8807221200 |
8807221217 |
8807221200 |
8810160901 |
8810160901 |
Hi - here's a simple head-start to get a count of each batch_id.
Question - why the aversion to creating an additional data set?
data dsn;
infile cards;
input Batch_ID;
cards;
8809510976
8807226488
8809932795
8810161136
8810161136
8810172306
8809510752
8809436613
8809510734
8809510734
8810207111
8809510734
8810160901
8810207111
8809724861
8807221194
8807221200
8807221205
8807221217
8807221217
8807221217
8807221217
8807221200
8807221217
8807221200
8810160901
8810160901
run;
proc means nway;
class batch_id;
output out=work.stats;
run;
Yes, I didn't create a another data set now. I was trying to not to overwrite the results.
But now, its working and I have the %age of duplicates as well.
proc sql;
create table duplicates_&p2 as
select (count(batch_id)- count(distinct(batch_id)))/count(batch_id)
as Duplicate format percent8.2,
month(datepart(Ptime_build)) as Month,
year(datepart(Ptime_Build)) as Year
from TABLE NAME
where "&Date_Range_Min."dt <= PTIME_BUILD <="&Date_Range_Max"dt and PTIME_BUILD is not missing
group by Month, Year;
quit;
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.
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.