Hello,
I am using proc sort by _all_ so that I can know if there is a duplicate records but SAS is producing a record at the dupout which is not a duplicate by _all_.
I have tried using nodupkey and nodup, but am getting the same result. My expectations is that by using _all_ , sas will sort by all variables within the each record. In the past someone raise the same issue in this community and someone suggested using first. and last. but will this works and how do I use first. and last. with _all_?
Is there any other way to sort by _All_ ? Any help will be highly appreciated. Thanks
Here is my code:
proc sort data=t nodup dupout=bc;
by _all_ ;
run;
proc sort data=y nodupkey dupout=z
by _all_ ;
run;
Are you 100% sure it's not a duplicate? As they say: "Nothing can put a knife in your back as good as your own data..."
1) run sort:
proc sort data=t out=t_sort;
by _all_ ;
run;
2) execute "first-last" check:
data t_sort_check;
set t_sort;
by _all_;
_compare_ = (first.<the name of the last variable in variables list> = last.<the name of the last variable in variables list>);
run;
data t_sort_checr_result;
set t_sort_check;
where compare_ = 0;
run;
(<the name of the last variable in variables list>
- replace this with proper variable name from the dataset, if you have: var1, var2, var3, ..., varN - use varN)
3) see what is in the t_sort_checr_result
All the best
Bart
Are you 100% sure it's not a duplicate? As they say: "Nothing can put a knife in your back as good as your own data..."
1) run sort:
proc sort data=t out=t_sort;
by _all_ ;
run;
2) execute "first-last" check:
data t_sort_check;
set t_sort;
by _all_;
_compare_ = (first.<the name of the last variable in variables list> = last.<the name of the last variable in variables list>);
run;
data t_sort_checr_result;
set t_sort_check;
where compare_ = 0;
run;
(<the name of the last variable in variables list>
- replace this with proper variable name from the dataset, if you have: var1, var2, var3, ..., varN - use varN)
3) see what is in the t_sort_checr_result
All the best
Bart
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.