I have a data with zip code and acc_nbr... when I sorted the data by zip code on different days, got same acct_nbr on different positions in the output data. Is it possible?
It’s possible...one way would be if you had ties in the data and they were sorted differently previously to this sort. So you have a different data set order passed to the proc sort with ties. If you have ties it’s best to do a double sort,with the first sort using an extra variable to control the order.
if you’re running the exact same program again, it’s unlikely. and I’d guess 99% of cases are some form of user error - like above.
@phadnismukta wrote:
I have a data with zip code and acc_nbr... when I sorted the data by zip code on different days, got same acct_nbr on different positions in the output data. Is it possible?
If you only sort by zip_number and not also by account_number within a zip number then yes, nothing will control the order of the account_numbers.
If your source table is a SAS data set (and not a database table) then using proc sort option EQUALS will return rows in the same "sub-" order as they were in the source table.
On top of what others said, certain means of storage (SPDS) might also influence the outcome of a sort.
See Maxim 31. Take control and force any order you need.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.