@HB wrote:
I think you need out=
https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/n1ab4sjiq6wxkvn1npo1pq1cvhxt.htm
Not needed though a good idea. See this log:
149 /* make a temporary data set to test the nodupkey with*/ 150 data class; 151 set sashelp.class; 152 run; NOTE: There were 19 observations read from the data set SASHELP.CLASS. NOTE: The data set WORK.CLASS has 19 observations and 5 variables. NOTE: DATA statement used (Total process time): real time 0.00 seconds cpu time 0.00 seconds 153 154 proc sort data=class nodupkey; 155 by sex age; 156 run; NOTE: There were 19 observations read from the data set WORK.CLASS. NOTE: 8 observations with duplicate key values were deleted. NOTE: The data set WORK.CLASS has 11 observations and 5 variables.
I used the Sashelp.class data set so others can test the code, making a copy in the Work library in the data step.
Then used Proc Sort with the Nodupkey option and no Out= option.
Notice that the resulting work.class data set now has 11 observations, not the 19 from copying Sashelp.class.
Proc sort will happily corrupt your source data set. So If you think that you may ever want to use the data from work.class from before the source then you should use an Out= option to create a new data set.
When you use BY _ALL_ there is a chance that values that look the same at first glance actually aren't. Formats for numeric values typically round. So a value of 1.999999999 and a format of BEST5. the displayed value will be 2.
Sometimes you have leading spaces in character values and depending on how you display them you can think they are the same but the leading space is significant when used as a By variable. Formats also come into play with character values as well. If the Format is $5. And you have values Blackstone and Blackheart they both, because of the format, display as Black. So you may want to check character variable length and format lengths.
Or the formats that may create groups.
Post usable example data that illustrates your issue.
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 16. 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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: