DATA Step, Macro, Functions and more

merge

Reply
Frequent Contributor
Frequent Contributor
Posts: 131

merge

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;

Super User
Posts: 10,568

Re: merge

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.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
PROC Star
Posts: 1,400

Re: merge

What does the error message in your log say?

Trusted Advisor
Posts: 1,848

Re: merge

[ Edited ]

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.

Super User
Posts: 6,931

Re: merge

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;

Super User
Posts: 13,926

Re: merge

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.

Ask a Question
Discussion stats
  • 5 replies
  • 185 views
  • 0 likes
  • 6 in conversation