Hello
I have a data set with one field and 2 rows.
In both rows there is same value "601_15013150_10_3021_604E3"
I am doing proc sort nodupkey and I still get 2 rows!!
May anyone help to solve the problem??
You don't provide any code nor sample data. Proc Sort Nodupkey just works - see below. If you don't get the expected result then either the data is different or something in your code isn't as it should.
For the data: Leading blanks or some hidden whitespace characters (characters that don't print) could make the strings different.
data have;
input var $20.;
output;
output;
datalines;
601_15013150_10_3021_604E3
;
proc sort data=have out=want nodupkey;
by var;
run;
proc print data=want;
run;
Please post data in usable form and show the log.
You don't provide any code nor sample data. Proc Sort Nodupkey just works - see below. If you don't get the expected result then either the data is different or something in your code isn't as it should.
For the data: Leading blanks or some hidden whitespace characters (characters that don't print) could make the strings different.
data have;
input var $20.;
output;
output;
datalines;
601_15013150_10_3021_604E3
;
proc sort data=have out=want nodupkey;
by var;
run;
proc print data=want;
run;
Yep.
I had an analogous behavior of getting "two identical values" (actually more than two, one for each level of a variable).
Traced it back that the file exported by the source for one of the sites collecting the data were exported as " the value" and "the value" for the others. So somehow one site had values with a leading space inserted into all of its values.
But the values in SAS are not the same with a leading space. (Actually this is only one of 100's of cases where the data provided does not actually match the provided data dictionary and field descriptions from that source. They don't update the dictionary as often as they change data fields).
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.