can anyone help me out in this
What type of library is PHW2022?
Your PROC SORT attempts to sort the data "in place", which means the output of the sort step will replace the table your are sorting. I recommend that you specify an OUT= table instead (if you can) to create a separate sorted table.
If your source library is a database (not a SAS data set), then the sort step may not be necessary and certainly isn't the same as a standard SAS data set file.
I don't think you can get that error from PROC SORT.
Read your log carefully and make sure that your sorted the dataset you intend to sort, and that the BY statement lists the variables in the same order as the BY statement of your data step that reads the data.
If you can post the full log showing the PROC SORT step and the step that generates the error, people will be able to help more.
PROC SORT cannot cause this ERROR, as its purpose is always to sort an unsorted dataset.
Please post your complete log (all code and messages) from PROC SORT to the occurrence of the ERROR by copy/pasting the log text into a window opened with this button:
Do NOT post code, logs or data as pictures. ALWAYS post text which we can copy into our SAS environment.
What code did you execute between that sort and the step that caused that error? A very likely cause of this error is a step between the sort and the code you ran that actually generated the error. Or opening the set in a table view and sorting interactively.
Please don't show pictures of code or log. Copy the text from the editor or log window, open a text box on the forum using the </> icon and paste the text.
If we need to make substantial changes to your code to fix a problem then it is much easier if we can edit text. If we have to retype code the longer it is the more likely you won't get a working solution from pictures.
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 25. 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.