I have this SAS code,
why Merge the last step dose not working:
PROC SORT DATA=REWK0.REWORK0500_CODECOUNT;
BY LOB Category Code CODE_DESCRIPTION;
RUN;
PROC SORT DATA=REWK0.Paid0500TRANS OUT=Paid0500TRANS;
BY LOB Category Code CODE_DESCRIPTION;
RUN;
DATA work.REWORK0500_codecount;
MERGE REWK0.REWORK0500_CODECOUNT Work.Paid0500TRANS;
BY LOB Category Code CODE_DESCRIPTION;
RUN;
Define "not working". "Does not work" is about as useful as the proverbial message about the sack of rice in China.
Post the log, and example of data and results not matching your expectations.
If you want us to test code, post example data in data steps.
What does the error message in your log say?
Your code should work unless you have a typo in dataset names or vaiables names..
Check your datasets spelling and if you have still issues post your log.
This code can fail if one of your BY variables meets these conditions. The variable is character, and has different lengths in the two incoming data sets.
The log should contain a warning about this, a warning which is fatal in this case. The solution is simple. Add a LENGTH statement before the MERGE statement, using the longer length from the two data sets. For example:
DATA work.REWORK0500_codecount;
length code $ 10;
MERGE REWK0.REWORK0500_CODECOUNT Work.Paid0500TRANS;
BY LOB Category Code CODE_DESCRIPTION;
RUN;
Doesn't work is awful vague.
Are there errors in the log?: Post the code and log in a code box opened with the {i} to maintain formatting of error messages.
No output? Post any log in a code box.
Unexpected output? Provide input data in the form of a dataset, the actual results and the expected results. Data should be in the form of a data step. Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.
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.